Skip to content

Commit 6616852

Browse files
committed
ch02: fix usage test and formatting
1 parent 3f8dd8e commit 6616852

File tree

1 file changed

+35
-18
lines changed

1 file changed

+35
-18
lines changed

02_crowsnest/test.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,32 @@
44
import os
55
from subprocess import getstatusoutput, getoutput
66

7-
prg = './crowsnest.py'
7+
prg = "crowsnest.py"
88
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+
"yatch",
29+
"zebrafish",
1330
]
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!"
1633

1734

1835
# --------------------------------------------------
@@ -26,43 +43,43 @@ def test_exists():
2643
def test_usage():
2744
"""usage"""
2845

29-
for flag in ['-h', '--help']:
30-
rv, out = getstatusoutput(f'{prg} {flag}')
46+
for flag in ["-h", "--help"]:
47+
rv, out = getstatusoutput(f"{prg} {flag}")
3148
assert rv == 0
32-
assert out.lower().startswith('usage')
49+
assert out.lower().startswith("usage")
3350

3451

3552
# --------------------------------------------------
3653
def test_consonant():
3754
"""brigantine -> a brigantine"""
3855

3956
for word in consonant_words:
40-
out = getoutput(f'{prg} {word}')
41-
assert out.strip() == template.format('a', word)
57+
out = getoutput(f"{prg} {word}")
58+
assert out.strip() == template.format("a", word)
4259

4360

4461
# --------------------------------------------------
4562
def test_consonant_upper():
4663
"""brigantine -> a Brigatine"""
4764

4865
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"{prg} {word.title()}")
67+
assert out.strip() == template.format("a", word.title())
5168

5269

5370
# --------------------------------------------------
5471
def test_vowel():
5572
"""octopus -> an octopus"""
5673

5774
for word in vowel_words:
58-
out = getoutput(f'{prg} {word}')
59-
assert out.strip() == template.format('an', word)
75+
out = getoutput(f"{prg} {word}")
76+
assert out.strip() == template.format("an", word)
6077

6178

6279
# --------------------------------------------------
6380
def test_vowel_upper():
6481
"""octopus -> an Octopus"""
6582

6683
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"{prg} {word.upper()}")
85+
assert out.strip() == template.format("an", word.upper())

0 commit comments

Comments
 (0)