From 119a8f3b2c8b744b2aa5ffcd746bbdc1a8bf1838 Mon Sep 17 00:00:00 2001 From: Frerk Saxen Date: Tue, 18 Jul 2023 12:07:29 +0200 Subject: [PATCH] test: test check-yaml feature that allows key duplicates. --- testing/resources/duplicate_key_yaml.notyaml | 2 ++ tests/check_yaml_test.py | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 testing/resources/duplicate_key_yaml.notyaml diff --git a/testing/resources/duplicate_key_yaml.notyaml b/testing/resources/duplicate_key_yaml.notyaml new file mode 100644 index 0000000..e682077 --- /dev/null +++ b/testing/resources/duplicate_key_yaml.notyaml @@ -0,0 +1,2 @@ +hello: "world" +hello: "planet" \ No newline at end of file diff --git a/tests/check_yaml_test.py b/tests/check_yaml_test.py index 54eb16e..ad059fa 100644 --- a/tests/check_yaml_test.py +++ b/tests/check_yaml_test.py @@ -27,6 +27,13 @@ def test_main_allow_multiple_documents(tmpdir): # should pass when we allow multiple documents assert not main(('--allow-multiple-documents', str(f))) +def test_main_allow_duplicate_keys(tmpdir): + f = get_resource_path('duplicate_key_yaml.notyaml') + # should fail by default + assert main((str(f),)) + # should pass when we allow duplicate keys + assert not main(('--allow-duplicate-keys', str(f))) + def test_fails_even_with_allow_multiple_documents(tmpdir): f = tmpdir.join('test.yaml')