summaryrefslogtreecommitdiff
path: root/_test/test_anchor.py
diff options
context:
space:
mode:
Diffstat (limited to '_test/test_anchor.py')
-rw-r--r--_test/test_anchor.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/_test/test_anchor.py b/_test/test_anchor.py
index 294d7f1..4c7a9f2 100644
--- a/_test/test_anchor.py
+++ b/_test/test_anchor.py
@@ -10,7 +10,7 @@ import pytest
from textwrap import dedent
import platform
-from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA
+from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump, YAML # NOQA
def load(s):
@@ -325,9 +325,8 @@ class TestMergeKeysValues:
d: y4
-
a: 1
- <<: *mx
+ <<: [*mx, *my]
m: 6
- <<: *my
""")
# in the following d always has "expanded" the merges
@@ -491,6 +490,29 @@ class TestDuplicateKeyThroughAnchor:
with pytest.raises(DuplicateKeyError):
round_trip_load(s)
+ def test_duplicate_key_01(self):
+ # so issue https://stackoverflow.com/a/52852106/1307905
+ from ruamel.yaml import version_info
+ from ruamel.yaml.constructor import DuplicateKeyFutureWarning, DuplicateKeyError
+
+ s = dedent("""\
+ - &name-name
+ a: 1
+ - &help-name
+ b: 2
+ - <<: *name-name
+ <<: *help-name
+ """)
+ if version_info < (0, 15, 1):
+ pass
+ else:
+ with pytest.raises(DuplicateKeyError):
+ yaml = YAML(typ='safe')
+ yaml.load(s)
+ with pytest.raises(DuplicateKeyError):
+ yaml = YAML()
+ yaml.load(s)
+
class TestFullCharSetAnchors:
def test_master_of_orion(self):