From e9e62df457a0c9ba125c979e36ab1bb90ef56e9b Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 28 Dec 2018 21:08:24 +0000 Subject: Add test for new-api `parse` method --- _test/test_api_change.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/_test/test_api_change.py b/_test/test_api_change.py index b7c3290..9bb26b5 100644 --- a/_test/test_api_change.py +++ b/_test/test_api_change.py @@ -135,6 +135,20 @@ class TestRead: yaml.load('a: 1') yaml.load('a: 1') # did not work in 0.15.4 + def test_parse(self): + # ensure `parse` method is functional and can parse "unsafe" yaml + from ruamel.yaml import YAML + from ruamel.yaml.constructor import ConstructorError + + yaml = YAML(typ='safe') + s = '- !User0 {age: 18, name: Anthon}' + # should fail to load + with pytest.raises(ConstructorError): + yaml.load(s) + # should parse fine + for _ in yaml.parse(s): + pass + class TestLoadAll: def test_multi_document_load(self, tmpdir): -- cgit v1.2.1