7
7
import string
8
8
from subprocess import getstatusoutput , getoutput
9
9
10
- prg = ' ./abuse.py'
10
+ PRG = " ./abuse.py"
11
11
12
12
13
13
# --------------------------------------------------
14
14
def test_exists ():
15
15
"""exists"""
16
16
17
- assert os .path .isfile (prg )
17
+ assert os .path .isfile (PRG )
18
18
19
19
20
20
# --------------------------------------------------
21
21
def test_usage ():
22
22
"""usage"""
23
23
24
- for flag in ['-h' , ' --help' ]:
25
- rv , out = getstatusoutput (f' { prg } { flag } ' )
24
+ for flag in ["-h" , " --help" ]:
25
+ rv , out = getstatusoutput (f"python3 { PRG } { flag } " )
26
26
assert rv == 0
27
27
assert re .match ("usage" , out , re .IGNORECASE )
28
28
@@ -32,7 +32,7 @@ def test_bad_adjective_str():
32
32
"""bad_adjectives"""
33
33
34
34
bad = random_string ()
35
- rv , out = getstatusoutput (f' { prg } -a { bad } ' )
35
+ rv , out = getstatusoutput (f"python3 { PRG } -a { bad } " )
36
36
assert rv != 0
37
37
assert re .search (f"invalid int value: '{ bad } '" , out )
38
38
@@ -42,18 +42,18 @@ def test_bad_adjective_num():
42
42
"""bad_adjectives"""
43
43
44
44
n = random .choice (range (- 10 , 0 ))
45
- rv , out = getstatusoutput (f' { prg } -a { n } ' )
45
+ rv , out = getstatusoutput (f"python3 { PRG } -a { n } " )
46
46
print (out )
47
47
assert rv != 0
48
- assert re .search (f'--adjectives "{ n } " must be > 0' , out )
48
+ assert re .search (f'--adjectives: "{ n } " must be > 0' , out )
49
49
50
50
51
51
# --------------------------------------------------
52
52
def test_bad_number_str ():
53
53
"""bad_number"""
54
54
55
55
bad = random_string ()
56
- rv , out = getstatusoutput (f' { prg } -n { bad } ' )
56
+ rv , out = getstatusoutput (f"python3 { PRG } -n { bad } " )
57
57
assert rv != 0
58
58
assert re .search (f"invalid int value: '{ bad } '" , out )
59
59
@@ -63,17 +63,17 @@ def test_bad_number_int():
63
63
"""bad_number"""
64
64
65
65
n = random .choice (range (- 10 , 0 ))
66
- rv , out = getstatusoutput (f' { prg } -n { n } ' )
66
+ rv , out = getstatusoutput (f"python3 { PRG } -n { n } " )
67
67
assert rv != 0
68
- assert re .search (f'--number "{ n } " must be > 0' , out )
68
+ assert re .search (f'--number: "{ n } " must be > 0' , out )
69
69
70
70
71
71
# --------------------------------------------------
72
72
def test_bad_seed ():
73
73
"""bad seed"""
74
74
75
75
bad = random_string ()
76
- rv , out = getstatusoutput (f' { prg } -s { bad } ' )
76
+ rv , out = getstatusoutput (f"python3 { PRG } -s { bad } " )
77
77
assert rv != 0
78
78
assert re .search (f"invalid int value: '{ bad } '" , out )
79
79
@@ -82,15 +82,15 @@ def test_bad_seed():
82
82
def test_01 ():
83
83
"""test"""
84
84
85
- out = getoutput (f' { prg } -s 1 -n 1' )
86
- assert out .strip () == ' You filthsome, cullionly fiend!'
85
+ out = getoutput (f"python3 { PRG } -s 1 -n 1" )
86
+ assert out .strip () == " You filthsome, cullionly fiend!"
87
87
88
88
89
89
# --------------------------------------------------
90
90
def test_02 ():
91
91
"""test"""
92
92
93
- out = getoutput (f' { prg } --seed 2' )
93
+ out = getoutput (f"python3 { PRG } --seed 2" )
94
94
expected = """
95
95
You corrupt, detestable beggar!
96
96
You peevish, foolish gull!
@@ -103,7 +103,7 @@ def test_02():
103
103
def test_03 ():
104
104
"""test"""
105
105
106
- out = getoutput (f' { prg } -s 3 -n 5 -a 1' )
106
+ out = getoutput (f"python3 { PRG } -s 3 -n 5 -a 1" )
107
107
expected = """
108
108
You infected villain!
109
109
You vile braggart!
@@ -118,7 +118,7 @@ def test_03():
118
118
def test_04 ():
119
119
"""test"""
120
120
121
- out = getoutput (f' { prg } --seed 4 --number 2 --adjectives 4' )
121
+ out = getoutput (f"python3 { PRG } --seed 4 --number 2 --adjectives 4" )
122
122
expected = """
123
123
You infected, lecherous, dishonest, rotten recreant!
124
124
You filthy, detestable, cullionly, base lunatic!
@@ -130,4 +130,4 @@ def test_04():
130
130
def random_string ():
131
131
"""generate a random filename"""
132
132
133
- return '' .join (random .choices (string .ascii_lowercase + string .digits , k = 5 ))
133
+ return "" .join (random .choices (string .ascii_lowercase + string .digits , k = 5 ))
0 commit comments