Add a test for custom ext.

This commit is contained in:
Rémy HUBSCHER 2020-02-05 18:39:50 +01:00
parent 04101b9c0a
commit fee5d54499
No known key found for this signature in database
GPG key ID: A500E24B95405094

View file

@ -36,7 +36,7 @@ def test_ok_with_dos_line_endings(tmpdir):
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):
path = tmpdir.join('test.md')
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', ''))
def test_markdown_linebreak_ext_badopt(arg):
with pytest.raises(SystemExit) as excinfo: