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')