Repository navigation
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·74 lines (51 loc) · 1.69 KB
/
Copy pathtest.py
File metadata and controls
executable file
·74 lines (51 loc) · 1.69 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
#!/usr/bin/env python3
"""tests for rhymer.py"""
import os
import random
from subprocess import getoutput
prg = './rhymer.py'
# --------------------------------------------------
def test_exists():
"""exists"""
assert os.path.isfile(prg)
# --------------------------------------------------
def test_usage():
"""usage"""
for flag in ['', '-h', '--help']:
out = getoutput(f'{prg} {flag}')
assert out.lower().startswith('usage')
# --------------------------------------------------
def test_take():
"""leading consonant"""
out = getoutput(f'{prg} take').splitlines()
assert len(out) == 56
assert out[0] == 'bake'
assert out[-1] == 'zake'
# --------------------------------------------------
def test_chair():
"""consonant cluster"""
out = getoutput(f'{prg} chair').splitlines()
assert len(out) == 56
assert out[1] == 'blair'
assert out[-2] == 'yair'
# --------------------------------------------------
def test_chair_uppercase():
"""consonant cluster"""
out = getoutput(f'{prg} CHAIR').splitlines()
assert len(out) == 56
assert out[1] == 'blair'
assert out[-2] == 'yair'
# --------------------------------------------------
def test_apple():
"""leading vowel"""
out = getoutput(f'{prg} apple').splitlines()
assert len(out) == 57
assert out[10] == 'flapple'
assert out[-10] == 'thwapple'
# --------------------------------------------------
def test_no_vowels():
"""no vowels"""
consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ'
bad = ''.join(random.sample(consonants, k=random.randint(4, 10)))
out = getoutput(f'{prg} {bad}')
assert out == f'Cannot rhyme "{bad}"'