mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 19:46:54 +00:00
Add "--check" option support to trailing_whitespace hook
This commit is contained in:
parent
3b8b26a097
commit
4842364696
2 changed files with 40 additions and 7 deletions
|
|
@ -18,6 +18,23 @@ def test_fixes_trailing_whitespace(input_s, expected, tmpdir):
|
|||
assert main((str(path),)) == 1
|
||||
assert path.read() == expected
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('input_s', 'exit_code', "lines"),
|
||||
(
|
||||
('foo \nbar \n', 1, [1,2]),
|
||||
('bar\t\nbaz\t\n', 1, [1,2]),
|
||||
('bar\nbaz\t\n', 1, [2]),
|
||||
),
|
||||
)
|
||||
def test_fixes_trailing_whitespace_check_only(capsys, input_s, exit_code, lines, tmpdir):
|
||||
path = tmpdir.join('file.md')
|
||||
path.write(input_s)
|
||||
assert main(('--check', str(path),)) == exit_code
|
||||
assert path.read() == input_s
|
||||
captured = capsys.readouterr()
|
||||
location = "@ " + ','.join(map(str, lines))
|
||||
assert location in captured.out
|
||||
|
||||
|
||||
def test_ok_no_newline_end_of_file(tmpdir):
|
||||
filename = tmpdir.join('f')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue