Add unit test for --no-ensure-ascii option
This commit is contained in:
parent
543c5c7e1a
commit
10f8bd2f22
|
@ -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'), (
|
||||
('not_pretty_formatted_json.json', 1),
|
||||
('unsorted_pretty_formatted_json.json', 1),
|
||||
('non_ascii_pretty_formatted_json.json', 1),
|
||||
('pretty_formatted_json.json', 0),
|
||||
))
|
||||
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'), (
|
||||
('not_pretty_formatted_json.json', 1),
|
||||
('unsorted_pretty_formatted_json.json', 0),
|
||||
('non_ascii_pretty_formatted_json.json', 1),
|
||||
('pretty_formatted_json.json', 0),
|
||||
))
|
||||
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'), (
|
||||
('not_pretty_formatted_json.json', 1),
|
||||
('unsorted_pretty_formatted_json.json', 1),
|
||||
('non_ascii_pretty_formatted_json.json', 1),
|
||||
('pretty_formatted_json.json', 1),
|
||||
('tab_pretty_formatted_json.json', 0),
|
||||
))
|
||||
|
@ -48,6 +51,11 @@ def test_tab_pretty_format_json(filename, 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):
|
||||
srcfile = tmpdir.join('to_be_json_formatted.json')
|
||||
shutil.copyfile(
|
||||
|
|
Loading…
Reference in New Issue