summaryrefslogtreecommitdiff
path: root/_test/test_api_change.py
blob: 10997f48dd81d27c9fa94b368c9dd74b22a08ca3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# coding: utf-8

"""
testing of anchors and the aliases referring to them
"""

import pytest
from ruamel.yaml import YAML
from ruamel.yaml.constructor import DuplicateKeyError


class TestNewAPI:
    def test_duplicate_keys_00(self):
        from ruamel.yaml.constructor import DuplicateKeyError
        yaml = YAML()
        with pytest.raises(DuplicateKeyError):
            yaml.load('{a: 1, a: 2}')

    def test_duplicate_keys_01(self):
        yaml = YAML(typ='safe', pure=True)
        with pytest.raises(DuplicateKeyError):
            yaml.load('{a: 1, a: 2}')

    # @pytest.mark.xfail(strict=True)
    def test_duplicate_keys_02(self):
        yaml = YAML(typ='safe')
        with pytest.raises(DuplicateKeyError):
            yaml.load('{a: 1, a: 2}')