77import string
88from subprocess import getstatusoutput , getoutput
99
10- prg = ' ./abuse.py'
10+ PRG = " ./abuse.py"
1111
1212
1313# --------------------------------------------------
1414def test_exists ():
1515 """exists"""
1616
17- assert os .path .isfile (prg )
17+ assert os .path .isfile (PRG )
1818
1919
2020# --------------------------------------------------
2121def test_usage ():
2222 """usage"""
2323
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 } " )
2626 assert rv == 0
2727 assert re .match ("usage" , out , re .IGNORECASE )
2828
@@ -32,7 +32,7 @@ def test_bad_adjective_str():
3232 """bad_adjectives"""
3333
3434 bad = random_string ()
35- rv , out = getstatusoutput (f' { prg } -a { bad } ' )
35+ rv , out = getstatusoutput (f"python3 { PRG } -a { bad } " )
3636 assert rv != 0
3737 assert re .search (f"invalid int value: '{ bad } '" , out )
3838
@@ -42,18 +42,18 @@ def test_bad_adjective_num():
4242 """bad_adjectives"""
4343
4444 n = random .choice (range (- 10 , 0 ))
45- rv , out = getstatusoutput (f' { prg } -a { n } ' )
45+ rv , out = getstatusoutput (f"python3 { PRG } -a { n } " )
4646 print (out )
4747 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 )
4949
5050
5151# --------------------------------------------------
5252def test_bad_number_str ():
5353 """bad_number"""
5454
5555 bad = random_string ()
56- rv , out = getstatusoutput (f' { prg } -n { bad } ' )
56+ rv , out = getstatusoutput (f"python3 { PRG } -n { bad } " )
5757 assert rv != 0
5858 assert re .search (f"invalid int value: '{ bad } '" , out )
5959
@@ -63,17 +63,17 @@ def test_bad_number_int():
6363 """bad_number"""
6464
6565 n = random .choice (range (- 10 , 0 ))
66- rv , out = getstatusoutput (f' { prg } -n { n } ' )
66+ rv , out = getstatusoutput (f"python3 { PRG } -n { n } " )
6767 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 )
6969
7070
7171# --------------------------------------------------
7272def test_bad_seed ():
7373 """bad seed"""
7474
7575 bad = random_string ()
76- rv , out = getstatusoutput (f' { prg } -s { bad } ' )
76+ rv , out = getstatusoutput (f"python3 { PRG } -s { bad } " )
7777 assert rv != 0
7878 assert re .search (f"invalid int value: '{ bad } '" , out )
7979
@@ -82,15 +82,15 @@ def test_bad_seed():
8282def test_01 ():
8383 """test"""
8484
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!"
8787
8888
8989# --------------------------------------------------
9090def test_02 ():
9191 """test"""
9292
93- out = getoutput (f' { prg } --seed 2' )
93+ out = getoutput (f"python3 { PRG } --seed 2" )
9494 expected = """
9595You corrupt, detestable beggar!
9696You peevish, foolish gull!
@@ -103,7 +103,7 @@ def test_02():
103103def test_03 ():
104104 """test"""
105105
106- out = getoutput (f' { prg } -s 3 -n 5 -a 1' )
106+ out = getoutput (f"python3 { PRG } -s 3 -n 5 -a 1" )
107107 expected = """
108108You infected villain!
109109You vile braggart!
@@ -118,7 +118,7 @@ def test_03():
118118def test_04 ():
119119 """test"""
120120
121- out = getoutput (f' { prg } --seed 4 --number 2 --adjectives 4' )
121+ out = getoutput (f"python3 { PRG } --seed 4 --number 2 --adjectives 4" )
122122 expected = """
123123You infected, lecherous, dishonest, rotten recreant!
124124You filthy, detestable, cullionly, base lunatic!
@@ -130,4 +130,4 @@ def test_04():
130130def random_string ():
131131 """generate a random filename"""
132132
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