Fix pretty_format_json to use int indent

The indent parameter for json should be integer and under Python2 is
will raise an error if not. So switch from str to int and mention
default value in help text.
This commit is contained in:
Calum Lind 2017-12-10 09:34:36 +00:00
parent 00974efa31
commit 5b6ddaf9f7
2 changed files with 16 additions and 29 deletions

View file

@ -3,20 +3,16 @@ import shutil
import pytest
from six import PY2
from pre_commit_hooks.pretty_format_json import parse_indent
from pre_commit_hooks.pretty_format_json import parse_num_to_int
from pre_commit_hooks.pretty_format_json import pretty_format_json
from testing.util import get_resource_path
def test_parse_indent():
assert parse_indent('0') == ''
assert parse_indent('2') == ' '
assert parse_indent('\t') == '\t'
with pytest.raises(ValueError):
parse_indent('a')
with pytest.raises(ValueError):
parse_indent('-2')
def test_parse_num_to_int():
assert parse_num_to_int('0') == 0
assert parse_num_to_int('2') == 2
assert parse_num_to_int('\t') == '\t'
assert parse_num_to_int(' ') == ' '
@pytest.mark.parametrize(