|
4 | 4 | import os |
5 | 5 | from subprocess import getstatusoutput, getoutput |
6 | 6 |
|
7 | | -prg = './crowsnest.py' |
| 7 | +PRG = "./crowsnest.py" |
8 | 8 | consonant_words = [ |
9 | | - 'brigantine', 'clipper', 'dreadnought', 'frigate', 'galleon', 'haddock', |
10 | | - 'junk', 'ketch', 'longboat', 'mullet', 'narwhal', 'porpoise', 'quay', |
11 | | - 'regatta', 'submarine', 'tanker', 'vessel', 'whale', 'xebec', 'yatch', |
12 | | - 'zebrafish' |
| 9 | + "brigantine", |
| 10 | + "clipper", |
| 11 | + "dreadnought", |
| 12 | + "frigate", |
| 13 | + "galleon", |
| 14 | + "haddock", |
| 15 | + "junk", |
| 16 | + "ketch", |
| 17 | + "longboat", |
| 18 | + "mullet", |
| 19 | + "narwhal", |
| 20 | + "porpoise", |
| 21 | + "quay", |
| 22 | + "regatta", |
| 23 | + "submarine", |
| 24 | + "tanker", |
| 25 | + "vessel", |
| 26 | + "whale", |
| 27 | + "xebec", |
| 28 | + "yacht", |
| 29 | + "zebrafish", |
13 | 30 | ] |
14 | | -vowel_words = ['aviso', 'eel', 'iceberg', 'octopus', 'upbound'] |
15 | | -template = 'Ahoy, Captain, {} {} off the larboard bow!' |
| 31 | +vowel_words = ["aviso", "eel", "iceberg", "octopus", "upbound"] |
| 32 | +TEMPLATE = "Ahoy, Captain, {} {} off the larboard bow!" |
16 | 33 |
|
17 | 34 |
|
18 | 35 | # -------------------------------------------------- |
19 | 36 | def test_exists(): |
20 | 37 | """exists""" |
21 | 38 |
|
22 | | - assert os.path.isfile(prg) |
| 39 | + assert os.path.isfile(PRG) |
23 | 40 |
|
24 | 41 |
|
25 | 42 | # -------------------------------------------------- |
26 | 43 | def test_usage(): |
27 | 44 | """usage""" |
28 | 45 |
|
29 | | - for flag in ['-h', '--help']: |
30 | | - rv, out = getstatusoutput(f'{prg} {flag}') |
| 46 | + for flag in ["-h", "--help"]: |
| 47 | + rv, out = getstatusoutput(f"python3 {PRG} {flag}") |
31 | 48 | assert rv == 0 |
32 | | - assert out.lower().startswith('usage') |
| 49 | + assert out.lower().startswith("usage") |
33 | 50 |
|
34 | 51 |
|
35 | 52 | # -------------------------------------------------- |
36 | 53 | def test_consonant(): |
37 | 54 | """brigantine -> a brigantine""" |
38 | 55 |
|
39 | 56 | for word in consonant_words: |
40 | | - out = getoutput(f'{prg} {word}') |
41 | | - assert out.strip() == template.format('a', word) |
| 57 | + out = getoutput(f"python3 {PRG} {word}") |
| 58 | + assert out.strip() == TEMPLATE.format("a", word) |
42 | 59 |
|
43 | 60 |
|
44 | 61 | # -------------------------------------------------- |
45 | 62 | def test_consonant_upper(): |
46 | 63 | """brigantine -> a Brigatine""" |
47 | 64 |
|
48 | 65 | for word in consonant_words: |
49 | | - out = getoutput(f'{prg} {word.title()}') |
50 | | - assert out.strip() == template.format('a', word.title()) |
| 66 | + out = getoutput(f"python3 {PRG} {word.title()}") |
| 67 | + assert out.strip() == TEMPLATE.format("A", word.title()) |
51 | 68 |
|
52 | 69 |
|
53 | 70 | # -------------------------------------------------- |
54 | 71 | def test_vowel(): |
55 | 72 | """octopus -> an octopus""" |
56 | 73 |
|
57 | 74 | for word in vowel_words: |
58 | | - out = getoutput(f'{prg} {word}') |
59 | | - assert out.strip() == template.format('an', word) |
| 75 | + out = getoutput(f"python3 {PRG} {word}") |
| 76 | + assert out.strip() == TEMPLATE.format("an", word) |
60 | 77 |
|
61 | 78 |
|
62 | 79 | # -------------------------------------------------- |
63 | 80 | def test_vowel_upper(): |
64 | 81 | """octopus -> an Octopus""" |
65 | 82 |
|
66 | 83 | for word in vowel_words: |
67 | | - out = getoutput(f'{prg} {word.upper()}') |
68 | | - assert out.strip() == template.format('an', word.upper()) |
| 84 | + out = getoutput(f"python3 {PRG} {word.upper()}") |
| 85 | + assert out.strip() == TEMPLATE.format("An", word.upper()) |
0 commit comments