Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·104 lines (67 loc) · 2.31 KB
/
Copy pathtest.py
File metadata and controls
executable file
·104 lines (67 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env python3
"""tests for friar.py"""
import os
import re
from subprocess import getstatusoutput, getoutput
prg = './friar.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# --------------------------------------------------
def test_usage():
"""usage"""
for flag in ['-h', '--help']:
rv, out = getstatusoutput(f'{prg} {flag}')
assert rv == 0
assert re.match("usage", out, re.IGNORECASE)
# --------------------------------------------------
def test_two_syllable_ing_words():
"""two-syllable ing words"""
tests = [("cooking", "cookin'"), ("Fishing", "Fishin'")]
for given, expected in tests:
out = getoutput(f'{prg} {given}')
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_one_syllable_ing_words():
"""one syllable ing words"""
tests = [("sing", "sing"), ("Fling", "Fling")]
for given, expected in tests:
out = getoutput(f'{prg} {given}')
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_you_yall():
"""you/y'all"""
tests = [("you", "y'all"), ("You", "Y'all")]
for given, expected in tests:
out = getoutput(f'{prg} {given}')
assert out.strip() == expected.strip()
# --------------------------------------------------
def run_file(file):
"""run with file"""
assert os.path.isfile(file)
expected_file = file + '.out'
assert os.path.isfile(expected_file)
expected = open(expected_file).read()
out = getoutput(f'{prg} {file}')
assert out.strip() == expected.strip()
# --------------------------------------------------
def test_blake():
"""blake"""
run_file('inputs/blake.txt')
# --------------------------------------------------
def test_banner():
"""banner"""
run_file('inputs/banner.txt')
# --------------------------------------------------
def test_raven():
"""raven"""
run_file('inputs/raven.txt')
# --------------------------------------------------
def test_dickinson():
"""dickinson"""
run_file('inputs/dickinson.txt')
# --------------------------------------------------
def test_shakespeare():
"""shakespeare"""
run_file('inputs/shakespeare.txt')