Skip to content

Commit 400f175

Browse files
committed
add pytest tests
1 parent 6e2b5e0 commit 400f175

File tree

4 files changed

+3150
-0
lines changed

4 files changed

+3150
-0
lines changed

dev-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pytest
2+
subprocess32

pyfiglet/tests/__init__.py

Whitespace-only changes.

pyfiglet/tests/test_cli.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import os
2+
3+
import pytest
4+
import subprocess32
5+
6+
7+
@pytest.fixture
8+
def test_font_dir():
9+
swd = os.path.dirname(os.path.abspath(__file__))
10+
return os.path.abspath(os.path.join(swd, '..', '..', 'test-fonts'))
11+
12+
13+
def test_strip():
14+
command = "pyfiglet -f doh -s 0"
15+
expected = '''\
16+
000000000
17+
00:::::::::00
18+
00:::::::::::::00
19+
0:::::::000:::::::0
20+
0::::::0 0::::::0
21+
0:::::0 0:::::0
22+
0:::::0 0:::::0
23+
0:::::0 000 0:::::0
24+
0:::::0 000 0:::::0
25+
0:::::0 0:::::0
26+
0:::::0 0:::::0
27+
0::::::0 0::::::0
28+
0:::::::000:::::::0
29+
00:::::::::::::00
30+
00:::::::::00
31+
000000000
32+
'''
33+
result = subprocess32.run(command, shell=True, stdout=subprocess32.PIPE)
34+
assert result.stdout.decode() == expected
35+
assert result.returncode == 0
36+
37+
38+
def test_strip_strange_font(test_font_dir):
39+
install_command = "pyfiglet -L %s/TEST_ONLY.flf " % test_font_dir
40+
subprocess32.run(install_command, shell=True, check=True)
41+
42+
command = "pyfiglet -f TEST_ONLY -s 0"
43+
expected = '''\
44+
0000000000
45+
46+
000 000
47+
48+
000 000
49+
50+
000 000
51+
52+
0000000000
53+
'''
54+
result = subprocess32.run(command, shell=True, stdout=subprocess32.PIPE)
55+
assert result.stdout.decode() == expected
56+
assert result.returncode == 0
57+
58+
59+
# normalize is just strip with padding
60+
def test_normalize():
61+
command = "pyfiglet -f doh -n 0"
62+
expected = '''\
63+
64+
000000000
65+
00:::::::::00
66+
00:::::::::::::00
67+
0:::::::000:::::::0
68+
0::::::0 0::::::0
69+
0:::::0 0:::::0
70+
0:::::0 0:::::0
71+
0:::::0 000 0:::::0
72+
0:::::0 000 0:::::0
73+
0:::::0 0:::::0
74+
0:::::0 0:::::0
75+
0::::::0 0::::::0
76+
0:::::::000:::::::0
77+
00:::::::::::::00
78+
00:::::::::00
79+
000000000
80+
81+
'''
82+
result = subprocess32.run(command, shell=True, stdout=subprocess32.PIPE)
83+
assert result.stdout.decode() == expected
84+
assert result.returncode == 0

0 commit comments

Comments
 (0)