Add test for '--no-sort-keys'
diff --git a/testing/resources/unsorted_pretty_formatted_json.json b/testing/resources/unsorted_pretty_formatted_json.json new file mode 100644 index 0000000..fe8bf5e --- /dev/null +++ b/testing/resources/unsorted_pretty_formatted_json.json
@@ -0,0 +1,9 @@ +{ + "foo": "bar", + "alist": [ + 34, + 2, + 234 + ], + "blah": null +}
diff --git a/tests/pretty_format_json_test.py b/tests/pretty_format_json_test.py index 6165a13..443c20f 100644 --- a/tests/pretty_format_json_test.py +++ b/tests/pretty_format_json_test.py
@@ -8,6 +8,7 @@ @pytest.mark.parametrize(('filename', 'expected_retval'), ( ('not_pretty_formatted_json.json', 1), + ('unsorted_pretty_formatted_json.json', 1), ('pretty_formatted_json.json', 0), )) def test_pretty_format_json(filename, expected_retval): @@ -15,6 +16,16 @@ assert ret == expected_retval +@pytest.mark.parametrize(('filename', 'expected_retval'), ( + ('not_pretty_formatted_json.json', 1), + ('unsorted_pretty_formatted_json.json', 0), + ('pretty_formatted_json.json', 0), +)) +def test_unsorted_pretty_format_json(filename, expected_retval): + ret = pretty_format_json(['--no-sort-keys', get_resource_path(filename)]) + assert ret == expected_retval + + def test_autofix_pretty_format_json(tmpdir): srcfile = tmpdir.join('to_be_json_formatted.json') with io.open(get_resource_path('not_pretty_formatted_json.json')) as f: