7
7
import string
8
8
from subprocess import getstatusoutput
9
9
10
- prg = ' ./gashlycrumb.py'
10
+ prg = " ./gashlycrumb.py"
11
11
12
12
13
13
# --------------------------------------------------
14
14
def file_flag ():
15
15
"""Either -f or --file"""
16
16
17
- return '-f' if random .randint (0 , 1 ) else ' --file'
17
+ return "-f" if random .randint (0 , 1 ) else " --file"
18
18
19
19
20
20
# --------------------------------------------------
@@ -28,8 +28,8 @@ def test_exists():
28
28
def test_usage ():
29
29
"""usage"""
30
30
31
- for flag in ['-h' , ' --help' ]:
32
- rv , out = getstatusoutput (f' { prg } { flag } ' )
31
+ for flag in ["-h" , " --help" ]:
32
+ rv , out = getstatusoutput (f"python3 { prg } { flag } " )
33
33
assert rv == 0
34
34
assert re .match ("usage" , out , re .IGNORECASE )
35
35
@@ -40,7 +40,7 @@ def test_bad_file():
40
40
41
41
bad = random_string ()
42
42
letter = random .choice (string .ascii_lowercase )
43
- rv , out = getstatusoutput (f' { prg } { letter } -f { bad } ' )
43
+ rv , out = getstatusoutput (f"python3 { prg } { letter } -f { bad } " )
44
44
assert rv != 0
45
45
expected = f"No such file or directory: '{ bad } '"
46
46
assert re .search (expected , out )
@@ -50,52 +50,53 @@ def test_bad_file():
50
50
def test_a ():
51
51
"""Test for 'a'"""
52
52
53
- rv , out = getstatusoutput (f' { prg } a' )
53
+ rv , out = getstatusoutput (f"python3 { prg } a" )
54
54
assert rv == 0
55
- expected = ' A is for Amy who fell down the stairs.'
55
+ expected = " A is for Amy who fell down the stairs."
56
56
assert out .strip () == expected
57
57
58
58
59
59
# --------------------------------------------------
60
60
def test_b_c ():
61
61
"""Test for 'b c'"""
62
62
63
- rv , out = getstatusoutput (f' { prg } b c' )
63
+ rv , out = getstatusoutput (f"python3 { prg } b c" )
64
64
assert rv == 0
65
- expected = ('B is for Basil assaulted by bears.\n '
66
- 'C is for Clara who wasted away.' )
65
+ expected = "B is for Basil assaulted by bears.\n " "C is for Clara who wasted away."
67
66
assert out .strip () == expected
68
67
69
68
70
69
# --------------------------------------------------
71
70
def test_y ():
72
71
"""Test for 'y'"""
73
72
74
- rv , out = getstatusoutput (f' { prg } Y' )
73
+ rv , out = getstatusoutput (f"python3 { prg } Y" )
75
74
assert rv == 0
76
- expected = ' Y is for Yorick whose head was bashed in.'
75
+ expected = " Y is for Yorick whose head was bashed in."
77
76
assert out .strip () == expected
78
77
79
78
80
79
# --------------------------------------------------
81
80
def test_o_alternate ():
82
- """ Test for 'o' from 'alternate.txt' """
81
+ """Test for 'o' from 'alternate.txt'"""
83
82
84
- rv , out = getstatusoutput (f' { prg } o P q -f alternate.txt' )
83
+ rv , out = getstatusoutput (f"python3 { prg } o P q -f alternate.txt" )
85
84
assert rv == 0
86
- expected = ('O is for Orville, who fell in a canyon.\n '
87
- 'P is for Paul, strangled by his banyan.\n '
88
- 'Q is for Quintanna, flayed in the night.' )
85
+ expected = (
86
+ "O is for Orville, who fell in a canyon.\n "
87
+ "P is for Paul, strangled by his banyan.\n "
88
+ "Q is for Quintanna, flayed in the night."
89
+ )
89
90
assert out .strip () == expected
90
91
91
92
92
93
# --------------------------------------------------
93
94
def test_bad_letter ():
94
95
"""Test for bad input"""
95
96
96
- rv , out = getstatusoutput (f' { prg } 5 CH' )
97
+ rv , out = getstatusoutput (f"python3 { prg } 5 CH" )
97
98
assert rv == 0
98
- expected = ( 'I do not know "5".\n ' 'I do not know "CH".' )
99
+ expected = 'I do not know "5".\n ' 'I do not know "CH".'
99
100
assert out .strip () == expected
100
101
101
102
@@ -104,4 +105,4 @@ def random_string():
104
105
"""generate a random string"""
105
106
106
107
k = random .randint (5 , 10 )
107
- return '' .join (random .choices (string .ascii_letters + string .digits , k = k ))
108
+ return "" .join (random .choices (string .ascii_letters + string .digits , k = k ))
0 commit comments