Update README.md about file-contents-sorter

This commit is contained in:
Daniel Gallagher 2017-06-23 11:32:05 -07:00
parent 8b41c575db
commit 4af7451154
2 changed files with 13 additions and 14 deletions

View file

@ -1,29 +1,26 @@
from argparse import ArgumentError
import pytest
from pre_commit_hooks.file_contents_sorter import FAIL
from pre_commit_hooks.file_contents_sorter import main
from pre_commit_hooks.file_contents_sorter import parse_commandline_input
from pre_commit_hooks.file_contents_sorter import PASS
from pre_commit_hooks.file_contents_sorter import sort_file_contents
def _n(*strs):
return b'\n'.join(strs) + '\n'
return b'\n'.join(strs) + b'\n'
# Input, expected return value, expected output
TESTS = (
(b'', PASS, b''),
(_n('lonesome'), PASS, _n('lonesome')),
(_n(b'lonesome'), PASS, _n(b'lonesome')),
(b'missing_newline', PASS, b'missing_newline'),
(_n('alpha', 'beta'), PASS, _n('alpha', 'beta')),
(_n('beta', 'alpha'), FAIL, _n('alpha', 'beta')),
(_n('C', 'c'), PASS, _n('C', 'c')),
(_n('c', 'C'), FAIL, _n('C', 'c')),
(_n('mag ical ', ' tre vor'), FAIL, _n(' tre vor', 'mag ical ')),
(_n('@', '-', '_', '#'), FAIL, _n('#', '-', '@', '_')),
(_n(b'alpha', b'beta'), PASS, _n(b'alpha', b'beta')),
(_n(b'beta', b'alpha'), FAIL, _n(b'alpha', b'beta')),
(_n(b'C', b'c'), PASS, _n(b'C', b'c')),
(_n(b'c', b'C'), FAIL, _n(b'C', b'c')),
(_n(b'mag ical ', b' tre vor'), FAIL, _n(b' tre vor', b'mag ical ')),
(_n(b'@', b'-', b'_', b'#'), FAIL, _n(b'#', b'-', b'@', b'_')),
)
@ -42,13 +39,14 @@ def test_parse_commandline_input_errors_without_args():
with pytest.raises(SystemExit):
parse_commandline_input([])
@pytest.mark.parametrize(
('filename_list'),
('filename_list'),
(
['filename1'],
['filename1'],
['filename1', 'filename2'],
)
)
def test_parse_commandline_input_success(filename_list):
args = parse_commandline_input(filename_list)
assert args.filenames == filename_list
assert args.filenames == filename_list