mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 11:36:54 +00:00
Add a test for custom ext.
This commit is contained in:
parent
04101b9c0a
commit
fee5d54499
1 changed files with 22 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ def test_ok_with_dos_line_endings(tmpdir):
|
||||||
assert ret == 0
|
assert ret == 0
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('ext', ('md', 'Md', '.md', '*', '.md.j2'))
|
@pytest.mark.parametrize('ext', ('md', 'Md', '.md', '*'))
|
||||||
def test_fixes_markdown_files(tmpdir, ext):
|
def test_fixes_markdown_files(tmpdir, ext):
|
||||||
path = tmpdir.join('test.md')
|
path = tmpdir.join('test.md')
|
||||||
path.write(
|
path.write(
|
||||||
|
|
@ -57,6 +57,27 @@ def test_fixes_markdown_files(tmpdir, ext):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize('ext', ('.md.j2'))
|
||||||
|
def test_fixes_custom_ext_markdown_files(tmpdir, ext):
|
||||||
|
path = tmpdir.join(f'test.{ext}')
|
||||||
|
path.write(
|
||||||
|
'foo \n' # leaves alone
|
||||||
|
'bar \n' # less than two so it is removed
|
||||||
|
'baz \n' # more than two so it becomes two spaces
|
||||||
|
'\t\n' # trailing tabs are stripped anyway
|
||||||
|
'\n ', # whitespace at the end of the file is removed
|
||||||
|
)
|
||||||
|
ret = main((path.strpath, '--markdown-linebreak-ext={}'.format(ext)))
|
||||||
|
assert ret == 1
|
||||||
|
assert path.read() == (
|
||||||
|
'foo \n'
|
||||||
|
'bar\n'
|
||||||
|
'baz \n'
|
||||||
|
'\n'
|
||||||
|
'\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('arg', ('--', 'a/b', ''))
|
@pytest.mark.parametrize('arg', ('--', 'a/b', ''))
|
||||||
def test_markdown_linebreak_ext_badopt(arg):
|
def test_markdown_linebreak_ext_badopt(arg):
|
||||||
with pytest.raises(SystemExit) as excinfo:
|
with pytest.raises(SystemExit) as excinfo:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue