Skip to content

Commit 1566cf9

Browse files
committed
Add test for mixed line endings output
1 parent 59ed512 commit 1566cf9

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/mixed_line_ending_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,38 @@ def test_mixed_no_newline_end_of_file(tmpdir):
6666
('--fix=lf', b'foo\nbar\nbaz\n'),
6767
),
6868
)
69-
def test_line_endings_ok(fix_option, input_s, tmpdir):
69+
def test_line_endings_ok(fix_option, input_s, tmpdir, capsys):
7070
path = tmpdir.join('input.txt')
7171
path.write_binary(input_s)
7272
ret = main((fix_option, path.strpath))
7373

7474
assert ret == 0
7575
assert path.read_binary() == input_s
76+
out, _ = capsys.readouterr()
77+
assert out == ''
7678

7779

78-
def test_no_fix_does_not_modify(tmpdir):
80+
def test_no_fix_does_not_modify(tmpdir, capsys):
7981
path = tmpdir.join('input.txt')
8082
contents = b'foo\r\nbar\rbaz\nwomp\n'
8183
path.write_binary(contents)
8284
ret = main(('--fix=no', path.strpath))
8385

8486
assert ret == 1
8587
assert path.read_binary() == contents
88+
out, _ = capsys.readouterr()
89+
assert out == '{}: mixed line endings\n'.format(path)
8690

8791

88-
def test_fix_lf(tmpdir):
92+
def test_fix_lf(tmpdir, capsys):
8993
path = tmpdir.join('input.txt')
9094
path.write_binary(b'foo\r\nbar\rbaz\n')
9195
ret = main(('--fix=lf', path.strpath))
9296

9397
assert ret == 1
9498
assert path.read_binary() == b'foo\nbar\nbaz\n'
99+
out, _ = capsys.readouterr()
100+
assert out == '{}: fixed mixed line endings\n'.format(path)
95101

96102

97103
def test_fix_crlf(tmpdir):

0 commit comments

Comments
 (0)