summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2018-12-28 21:08:24 +0000
committerAnthony Sottile <asottile@umich.edu>2018-12-28 21:08:24 +0000
commite9e62df457a0c9ba125c979e36ab1bb90ef56e9b (patch)
tree8485c3d61d688152cf09ba232fcad40e217349d3 /_test
parentc59babd740f7d6cfd865626f0a0427de8c320987 (diff)
downloadruamel.yaml-e9e62df457a0c9ba125c979e36ab1bb90ef56e9b.tar.gz
Add test for new-api `parse` method
Diffstat (limited to '_test')
-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):