mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2025-08-26 10:02:22 +08:00
Add test for '--no-sort-keys'
This commit is contained in:
@ -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:
|
||||
|
Reference in New Issue
Block a user