summaryrefslogtreecommitdiff
path: root/_test
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-08-18 12:57:24 +0200
committerAnthon van der Neut <anthon@mnt.org>2016-08-18 12:57:24 +0200
commitc9331e372f1aeef155db22fe88efeec775507c67 (patch)
treeeb9ba9df1e9eef7fa22dd9e737eae35e242b9ed3 /_test
parentf21343115c0b7f2849766f741bbe64e6c170a556 (diff)
downloadruamel.yaml-c9331e372f1aeef155db22fe88efeec775507c67.tar.gz
fix merge, iteration, reused anchors0.12.3
Diffstat (limited to '_test')
-rw-r--r--_test/test_anchor.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/_test/test_anchor.py b/_test/test_anchor.py
index 1c795c0..593bf8a 100644
--- a/_test/test_anchor.py
+++ b/_test/test_anchor.py
@@ -9,6 +9,8 @@ from textwrap import dedent
import platform
from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA
+from ruamel.yaml.compat import PY3
+from ruamel.yaml.error import ReusedAnchorWarning
def load(s):
@@ -228,6 +230,19 @@ class TestAnchorsAliases:
b: 2
""")
+ # this is an error in PyYAML
+ def test_reused_anchor(self):
+ yaml = '''
+ - &a
+ x: 1
+ - <<: *a
+ - &a
+ x: 2
+ - <<: *a
+ '''
+ with pytest.warns(ReusedAnchorWarning):
+ data = round_trip(yaml) # NOQA
+
class TestMergeKeysValues:
@@ -247,6 +262,8 @@ class TestMergeKeysValues:
<<: *my
""")
+ # in the following d always has "expanded" the merges
+
def test_merge_for(self):
from ruamel.yaml import safe_load
d = safe_load(self.yaml_str)
@@ -286,3 +303,23 @@ class TestMergeKeysValues:
count += 1
print(count, x)
assert count == len(d[2])
+
+ def test_len_items_delete(self):
+ from ruamel.yaml import safe_load
+ d = safe_load(self.yaml_str)
+ data = round_trip_load(self.yaml_str)
+ x = data[2].items()
+ ref = len(d[2].items())
+ assert len(x) == ref
+ del data[2]['m']
+ if PY3:
+ ref -= 1
+ assert len(x) == ref
+ del data[2]['d']
+ if PY3:
+ ref -= 1
+ assert len(x) == ref
+ del data[2]['a']
+ if PY3:
+ ref -= 1
+ assert len(x) == ref