Skip to content

Commit bd4e37c

Browse files
committed
Add test for '--no-sort-keys'
1 parent 700b18e commit bd4e37c

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"foo": "bar",
3+
"alist": [
4+
34,
5+
2,
6+
234
7+
],
8+
"blah": null
9+
}

‎tests/pretty_format_json_test.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@
88

99
@pytest.mark.parametrize(('filename', 'expected_retval'), (
1010
('not_pretty_formatted_json.json', 1),
11+
('unsorted_pretty_formatted_json.json', 1),
1112
('pretty_formatted_json.json', 0),
1213
))
1314
def test_pretty_format_json(filename, expected_retval):
1415
ret = pretty_format_json([get_resource_path(filename)])
1516
assert ret == expected_retval
1617

1718

19+
@pytest.mark.parametrize(('filename', 'expected_retval'), (
20+
('not_pretty_formatted_json.json', 1),
21+
('unsorted_pretty_formatted_json.json', 0),
22+
('pretty_formatted_json.json', 0),
23+
))
24+
def test_unsorted_pretty_format_json(filename, expected_retval):
25+
ret = pretty_format_json(['--no-sort-keys', get_resource_path(filename)])
26+
assert ret == expected_retval
27+
28+
1829
def test_autofix_pretty_format_json(tmpdir):
1930
srcfile = tmpdir.join('to_be_json_formatted.json')
2031
with io.open(get_resource_path('not_pretty_formatted_json.json')) as f:

0 commit comments

Comments
 (0)