summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuamel/Anthon van der Neut <bitbucket@ruamel.eu>2019-01-07 15:58:47 +0000
committerRuamel/Anthon van der Neut <bitbucket@ruamel.eu>2019-01-07 15:58:47 +0000
commit619842506decc4b036e06e5753f3f7476c036d41 (patch)
tree463ce64dc9453dae55fbefb1000f635418c735e8
parent8475a853ec2af50deafb1819584dc0a7ad24463a (diff)
parente9e62df457a0c9ba125c979e36ab1bb90ef56e9b (diff)
downloadruamel.yaml-619842506decc4b036e06e5753f3f7476c036d41.tar.gz
Merged in asottile/yaml-1/asottile/add-test-for-newapi-parse-method-1546031299922 (pull request #38)
Add test for new-api `parse` method
-rw-r--r--_test/test_api_change.py14
1 files changed, 14 insertions, 0 deletions
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):