diff options
author | Anthon van der Neut <anthon@mnt.org> | 2018-10-17 17:10:46 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2018-10-17 17:10:46 +0200 |
commit | a0d4b1a7f4998aa1d8015cf78bd043682bc9105b (patch) | |
tree | 44f79b8dba29cde1eb5c7afbe2ac35a393ef0c95 /_test | |
parent | 783c5c68171e5cfac583a1c49a1c66c9209c2211 (diff) | |
download | ruamel.yaml-a0d4b1a7f4998aa1d8015cf78bd043682bc9105b.tar.gz |
fix issue 251 error on multiple merge keys
Diffstat (limited to '_test')
-rw-r--r-- | _test/test_anchor.py | 28 |
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): |