Add test for '--no-sort-keys'

This commit is contained in:
mattclegg 2016-04-14 09:36:47 +01:00
parent 700b18ed0e
commit bd4e37c366
2 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,9 @@
{
"foo": "bar",
"alist": [
34,
2,
234
],
"blah": null
}

View File

@ -8,6 +8,7 @@ from testing.util import get_resource_path
@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 @@ def test_pretty_format_json(filename, expected_retval):
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: