From a7e27772f48e9e7f1040344739f680081da50a41 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Sat, 6 May 2023 12:29:03 +0200 Subject: fix issue: 453, 447 --- _test/test_issues.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to '_test') diff --git a/_test/test_issues.py b/_test/test_issues.py index ce78cce..eadf94d 100644 --- a/_test/test_issues.py +++ b/_test/test_issues.py @@ -954,6 +954,11 @@ class TestIssues: yaml.dump(data, buf) assert buf.getvalue() == '%YAML 1.1\n---\nquote: I have seen things\n' + def test_issue_447(self) -> None: + from ruamel.yaml import YAML + + YAML().load("{\n\t\"FOO\": \"BAR\"\n}") + def test_issue_449(self) -> None: inp = """\ emoji_index: !!python/name:materialx.emoji.twemoji @@ -974,6 +979,32 @@ class TestIssues: assert ord(k) == v assert len(cm) == 4 + def test_issue_453(self) -> None: + from io import StringIO + from ruamel.yaml import YAML + + inp = dedent( + """ + to-merge: &anchor + merge-key: should not be duplicated + + to-merge2: &anchor2 + merge-key2: should not be duplicated + + usage: + <<: [*anchor, *anchor2] + usage-key: usage-value + """ + ) + yaml = YAML() + data = yaml.load(inp) + data['usage'].insert(0, 'insert-key', 'insert-value') + out_stream = StringIO() + yaml.dump(data, out_stream) + result = out_stream.getvalue() + print(result) + assert inp.replace('usage:\n', 'usage:\n insert-key: insert-value\n') == result + def test_issue_454(self) -> None: inp = """ test1: 🎉 -- cgit v1.2.1