예제 #1
0
    def test_dup_merge(self):
        from ruyaml import YAML

        yaml = YAML()
        yaml.allow_duplicate_keys = True
        d = yaml.load("""\
        foo: &f
          a: a
        foo2: &g
          b: b
        all:
          <<: *f
          <<: *g
        """)['all']
        assert d == {'a': 'a', 'b': 'b'}
예제 #2
0
    def test_dup_merge_fail(self):
        from ruyaml import YAML
        from ruyaml.constructor import DuplicateKeyError

        yaml = YAML()
        yaml.allow_duplicate_keys = False
        with pytest.raises(DuplicateKeyError):
            yaml.load("""\
            foo: &f
              a: a
            foo2: &g
              b: b
            all:
              <<: *f
              <<: *g
            """)