mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-10 05:14:18 +00:00
Add unit test for --no-ensure-ascii option
This commit is contained in:
parent
543c5c7e1a
commit
10f8bd2f22
2 changed files with 18 additions and 0 deletions
10
testing/resources/non_ascii_pretty_formatted_json.json
Normal file
10
testing/resources/non_ascii_pretty_formatted_json.json
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"alist": [
|
||||||
|
2,
|
||||||
|
34,
|
||||||
|
234
|
||||||
|
],
|
||||||
|
"blah": null,
|
||||||
|
"foo": "bar",
|
||||||
|
"non_ascii": "中文にほんご한국어"
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ def test_parse_indent():
|
||||||
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
||||||
('not_pretty_formatted_json.json', 1),
|
('not_pretty_formatted_json.json', 1),
|
||||||
('unsorted_pretty_formatted_json.json', 1),
|
('unsorted_pretty_formatted_json.json', 1),
|
||||||
|
('non_ascii_pretty_formatted_json.json', 1),
|
||||||
('pretty_formatted_json.json', 0),
|
('pretty_formatted_json.json', 0),
|
||||||
))
|
))
|
||||||
def test_pretty_format_json(filename, expected_retval):
|
def test_pretty_format_json(filename, expected_retval):
|
||||||
|
|
@ -30,6 +31,7 @@ def test_pretty_format_json(filename, expected_retval):
|
||||||
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
||||||
('not_pretty_formatted_json.json', 1),
|
('not_pretty_formatted_json.json', 1),
|
||||||
('unsorted_pretty_formatted_json.json', 0),
|
('unsorted_pretty_formatted_json.json', 0),
|
||||||
|
('non_ascii_pretty_formatted_json.json', 1),
|
||||||
('pretty_formatted_json.json', 0),
|
('pretty_formatted_json.json', 0),
|
||||||
))
|
))
|
||||||
def test_unsorted_pretty_format_json(filename, expected_retval):
|
def test_unsorted_pretty_format_json(filename, expected_retval):
|
||||||
|
|
@ -40,6 +42,7 @@ def test_unsorted_pretty_format_json(filename, expected_retval):
|
||||||
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
@pytest.mark.parametrize(('filename', 'expected_retval'), (
|
||||||
('not_pretty_formatted_json.json', 1),
|
('not_pretty_formatted_json.json', 1),
|
||||||
('unsorted_pretty_formatted_json.json', 1),
|
('unsorted_pretty_formatted_json.json', 1),
|
||||||
|
('non_ascii_pretty_formatted_json.json', 1),
|
||||||
('pretty_formatted_json.json', 1),
|
('pretty_formatted_json.json', 1),
|
||||||
('tab_pretty_formatted_json.json', 0),
|
('tab_pretty_formatted_json.json', 0),
|
||||||
))
|
))
|
||||||
|
|
@ -48,6 +51,11 @@ def test_tab_pretty_format_json(filename, expected_retval):
|
||||||
assert ret == expected_retval
|
assert ret == expected_retval
|
||||||
|
|
||||||
|
|
||||||
|
def test_non_ascii_pretty_format_json():
|
||||||
|
ret = pretty_format_json(['--no-ensure-ascii', get_resource_path('non_ascii_pretty_formatted_json.json')])
|
||||||
|
assert ret == 0
|
||||||
|
|
||||||
|
|
||||||
def test_autofix_pretty_format_json(tmpdir):
|
def test_autofix_pretty_format_json(tmpdir):
|
||||||
srcfile = tmpdir.join('to_be_json_formatted.json')
|
srcfile = tmpdir.join('to_be_json_formatted.json')
|
||||||
shutil.copyfile(
|
shutil.copyfile(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue