Coverage for test_e20_wc.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from e20_wc import wc
2import pytest
3from io import StringIO
6@pytest.fixture
7def empty_file(tmp_path):
8 f = tmp_path / 'textfile'
9 f.write_text('')
10 return f
13@pytest.fixture
14def simple_file(tmp_path):
15 f = tmp_path / 'wcfile.txt'
16 f.write_text('''This is a test file.
18It contains 28 words and 20 different words.
20It also contains 165 characters.
22It also contains 11 lines.
24It is also self-referential.
26Wow!''')
27 return f
30def test_empty(empty_file, capsys):
31 wc(empty_file)
32 captured_out, captured_err = capsys.readouterr()
33 assert captured_out == """characters: 0
34words: 0
35lines: 0
36unique words: 0
37"""
40def test_simple(simple_file, capsys):
41 wc(simple_file)
42 captured_out, captured_err = capsys.readouterr()
43 assert captured_out == """characters: 164
44words: 28
45lines: 11
46unique words: 20
47"""