|
5 | 5 | import random
|
6 | 6 | from subprocess import getoutput
|
7 | 7 |
|
8 |
| -prg = './rhymer.py' |
| 8 | +PRG = "./rhymer.py" |
9 | 9 |
|
10 | 10 |
|
11 | 11 | # --------------------------------------------------
|
12 | 12 | def test_exists():
|
13 | 13 | """exists"""
|
14 | 14 |
|
15 |
| - assert os.path.isfile(prg) |
| 15 | + assert os.path.isfile(PRG) |
16 | 16 |
|
17 | 17 |
|
18 | 18 | # --------------------------------------------------
|
19 | 19 | def test_usage():
|
20 | 20 | """usage"""
|
21 | 21 |
|
22 |
| - for flag in ['', '-h', '--help']: |
23 |
| - out = getoutput(f'{prg} {flag}') |
24 |
| - assert out.lower().startswith('usage') |
| 22 | + for flag in ["", "-h", "--help"]: |
| 23 | + out = getoutput(f"python {PRG} {flag}") |
| 24 | + assert out.lower().startswith("usage") |
25 | 25 |
|
26 | 26 |
|
27 | 27 | # --------------------------------------------------
|
28 | 28 | def test_take():
|
29 | 29 | """leading consonant"""
|
30 | 30 |
|
31 |
| - out = getoutput(f'{prg} take').splitlines() |
| 31 | + out = getoutput(f"python {PRG} take").splitlines() |
32 | 32 | assert len(out) == 56
|
33 |
| - assert out[0] == 'bake' |
34 |
| - assert out[-1] == 'zake' |
| 33 | + assert out[0] == "bake" |
| 34 | + assert out[-1] == "zake" |
35 | 35 |
|
36 | 36 |
|
37 | 37 | # --------------------------------------------------
|
38 | 38 | def test_chair():
|
39 | 39 | """consonant cluster"""
|
40 | 40 |
|
41 |
| - out = getoutput(f'{prg} chair').splitlines() |
| 41 | + out = getoutput(f"python {PRG} chair").splitlines() |
42 | 42 | assert len(out) == 56
|
43 |
| - assert out[1] == 'blair' |
44 |
| - assert out[-2] == 'yair' |
| 43 | + assert out[1] == "blair" |
| 44 | + assert out[-2] == "yair" |
45 | 45 |
|
46 | 46 |
|
47 | 47 | # --------------------------------------------------
|
48 | 48 | def test_chair_uppercase():
|
49 | 49 | """consonant cluster"""
|
50 | 50 |
|
51 |
| - out = getoutput(f'{prg} CHAIR').splitlines() |
| 51 | + out = getoutput(f"python {PRG} CHAIR").splitlines() |
52 | 52 | assert len(out) == 56
|
53 |
| - assert out[1] == 'blair' |
54 |
| - assert out[-2] == 'yair' |
| 53 | + assert out[1] == "blair" |
| 54 | + assert out[-2] == "yair" |
55 | 55 |
|
56 | 56 |
|
57 | 57 | # --------------------------------------------------
|
58 | 58 | def test_apple():
|
59 | 59 | """leading vowel"""
|
60 | 60 |
|
61 |
| - out = getoutput(f'{prg} apple').splitlines() |
| 61 | + out = getoutput(f"python {PRG} apple").splitlines() |
62 | 62 | assert len(out) == 57
|
63 |
| - assert out[10] == 'flapple' |
64 |
| - assert out[-10] == 'thwapple' |
| 63 | + assert out[10] == "flapple" |
| 64 | + assert out[-10] == "thwapple" |
65 | 65 |
|
66 | 66 |
|
67 | 67 | # --------------------------------------------------
|
68 | 68 | def test_no_vowels():
|
69 | 69 | """no vowels"""
|
70 | 70 |
|
71 |
| - consonants = 'bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ' |
72 |
| - bad = ''.join(random.sample(consonants, k=random.randint(4, 10))) |
73 |
| - out = getoutput(f'{prg} {bad}') |
| 71 | + consonants = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ" |
| 72 | + bad = "".join(random.sample(consonants, k=random.randint(4, 10))) |
| 73 | + out = getoutput(f"python {PRG} {bad}") |
74 | 74 | assert out == f'Cannot rhyme "{bad}"'
|
0 commit comments