mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 03:26:53 +00:00
Only return nonzero when rewriting whitespace
This commit is contained in:
parent
46251c9523
commit
81147337c5
3 changed files with 34 additions and 12 deletions
|
|
@ -20,6 +20,22 @@ def test_fixes_trailing_whitespace(input_s, expected, tmpdir):
|
|||
assert path.read() == expected
|
||||
|
||||
|
||||
def test_ok_with_dos_line_endings(tmpdir):
|
||||
filename = tmpdir.join('f')
|
||||
filename.write_binary(b'foo\r\nbar\r\nbaz\r\n')
|
||||
ret = fix_trailing_whitespace((filename.strpath,))
|
||||
assert filename.read_binary() == b'foo\r\nbar\r\nbaz\r\n'
|
||||
assert ret == 0
|
||||
|
||||
|
||||
def test_markdown_ok(tmpdir):
|
||||
filename = tmpdir.join('foo.md')
|
||||
filename.write_binary(b'foo \n')
|
||||
ret = fix_trailing_whitespace((filename.strpath,))
|
||||
assert filename.read_binary() == b'foo \n'
|
||||
assert ret == 0
|
||||
|
||||
|
||||
# filename, expected input, expected output
|
||||
MD_TESTS_1 = (
|
||||
('foo.md', 'foo \nbar \n ', 'foo \nbar\n\n'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue