77import string
88from subprocess import getstatusoutput
99
10- prg = ' ./password.py'
11- words = ' ../inputs/words .txt'
10+ PRG = " ./password.py"
11+ WORDS = " ../inputs/WORDS .txt"
1212
1313
1414# --------------------------------------------------
1515def test_exists ():
1616 """exists"""
1717
18- assert os .path .isfile (prg )
19- assert os .path .isfile (words )
18+ assert os .path .isfile (PRG )
19+ assert os .path .isfile (WORDS )
2020
2121
2222# --------------------------------------------------
2323def test_usage ():
2424 """usage"""
2525
26- for flag in ['-h' , ' --help' ]:
27- rv , out = getstatusoutput (f' { prg } { flag } ' )
26+ for flag in ["-h" , " --help" ]:
27+ rv , out = getstatusoutput (f"python { PRG } { flag } " )
2828 assert rv == 0
29- assert out .lower ().startswith (' usage' )
29+ assert out .lower ().startswith (" usage" )
3030
3131
3232# --------------------------------------------------
3333def test_bad_file ():
3434 """Dies on bad file"""
3535
3636 bad = random_string ()
37- rv , out = getstatusoutput (f' { prg } { bad } ' )
37+ rv , out = getstatusoutput (f"python { PRG } { bad } " )
3838 assert rv != 0
3939 assert re .search (f"No such file or directory: '{ bad } '" , out )
4040
@@ -44,19 +44,19 @@ def test_bad_num():
4444 """Dies on bad num"""
4545
4646 bad = random_string ()
47- flag = '-n' if random .choice ([0 , 1 ]) else ' --num'
48- rv , out = getstatusoutput (f' { prg } { flag } { bad } { words } ' )
47+ flag = "-n" if random .choice ([0 , 1 ]) else " --num"
48+ rv , out = getstatusoutput (f"python { PRG } { flag } { bad } { WORDS } " )
4949 assert rv != 0
5050 assert re .search (f"invalid int value: '{ bad } '" , out )
5151
5252
5353# --------------------------------------------------
54- def test_bad_num_words ():
54+ def test_bad_num_WORDS ():
5555 """Dies on bad num"""
5656
5757 bad = random_string ()
58- flag = '-w' if random .choice ([0 , 1 ]) else '--num_words'
59- rv , out = getstatusoutput (f' { prg } { flag } { bad } { words } ' )
58+ flag = "-w" if random .choice ([0 , 1 ]) else "--num_WORDS"
59+ rv , out = getstatusoutput (f"python { PRG } { flag } { bad } { WORDS } " )
6060 assert rv != 0
6161 assert re .search (f"invalid int value: '{ bad } '" , out )
6262
@@ -66,8 +66,8 @@ def test_bad_min_word_len():
6666 """Dies on bad min_word_len"""
6767
6868 bad = random_string ()
69- flag = '-m' if random .choice ([0 , 1 ]) else ' --min_word_len'
70- rv , out = getstatusoutput (f' { prg } { flag } { bad } { words } ' )
69+ flag = "-m" if random .choice ([0 , 1 ]) else " --min_word_len"
70+ rv , out = getstatusoutput (f"python { PRG } { flag } { bad } { WORDS } " )
7171 assert rv != 0
7272 assert re .search (f"invalid int value: '{ bad } '" , out )
7373
@@ -77,8 +77,8 @@ def test_bad_max_word_len():
7777 """Dies on bad max_word_len"""
7878
7979 bad = random_string ()
80- flag = '-m' if random .choice ([0 , 1 ]) else ' --max_word_len'
81- rv , out = getstatusoutput (f' { prg } { flag } { bad } { words } ' )
80+ flag = "-m" if random .choice ([0 , 1 ]) else " --max_word_len"
81+ rv , out = getstatusoutput (f"python { PRG } { flag } { bad } { WORDS } " )
8282 assert rv != 0
8383 assert re .search (f"invalid int value: '{ bad } '" , out )
8484
@@ -88,8 +88,8 @@ def test_bad_seed():
8888 """Dies on bad seed"""
8989
9090 bad = random_string ()
91- flag = '-s' if random .choice ([0 , 1 ]) else ' --seed'
92- rv , out = getstatusoutput (f' { prg } { flag } { bad } { words } ' )
91+ flag = "-s" if random .choice ([0 , 1 ]) else " --seed"
92+ rv , out = getstatusoutput (f"python { PRG } { flag } { bad } { WORDS } " )
9393 assert rv != 0
9494 assert re .search (f"invalid int value: '{ bad } '" , out )
9595
@@ -98,70 +98,71 @@ def test_bad_seed():
9898def test_defaults ():
9999 """Test"""
100100
101- rv , out = getstatusoutput (f' { prg } -s 1 { words } ' )
101+ rv , out = getstatusoutput (f"python { PRG } -s 1 { WORDS } " )
102102 assert rv == 0
103- assert out .strip () == ' \n ' .join ([
104- ' DuniteBoonLociDefat' , ' WegaTitmalUnplatSatire' , ' IdeanClipsVitiArriet'
105- ] )
103+ assert out .strip () == " \n " .join (
104+ [ " DuniteBoonLociDefat" , " WegaTitmalUnplatSatire" , " IdeanClipsVitiArriet" ]
105+ )
106106
107107
108108# --------------------------------------------------
109109def test_num ():
110110 """Test"""
111111
112- rv , out = getstatusoutput (f' { prg } -s 1 -n 1 { words } ' )
112+ rv , out = getstatusoutput (f"python { PRG } -s 1 -n 1 { WORDS } " )
113113 assert rv == 0
114- assert out .strip () == ' DuniteBoonLociDefat'
114+ assert out .strip () == " DuniteBoonLociDefat"
115115
116116
117117# --------------------------------------------------
118- def test_num_words ():
118+ def test_num_WORDS ():
119119 """Test"""
120120
121- rv , out = getstatusoutput (f' { prg } -s 1 -w 2 { words } ' )
121+ rv , out = getstatusoutput (f"python { PRG } -s 1 -w 2 { WORDS } " )
122122 assert rv == 0
123- assert out .strip () == ' \n ' .join ([' DuniteBoon' , ' LociDefat' , ' WegaTitmal' ])
123+ assert out .strip () == " \n " .join ([" DuniteBoon" , " LociDefat" , " WegaTitmal" ])
124124
125125
126126# --------------------------------------------------
127127def test_min_word_len ():
128128 """Test"""
129129
130- rv , out = getstatusoutput (f' { prg } -s 1 -m 5 { words } ' )
130+ rv , out = getstatusoutput (f"python { PRG } -s 1 -m 5 { WORDS } " )
131131 assert rv == 0
132- assert out .strip () == '\n ' .join ([
133- 'CarneyRapperWabenoUndine' , 'BabaiFarerBugleOnlepy' ,
134- 'UnbittMinnyNatalSkanda'
135- ])
132+ assert out .strip () == "\n " .join (
133+ ["CarneyRapperWabenoUndine" , "BabaiFarerBugleOnlepy" , "UnbittMinnyNatalSkanda" ]
134+ )
136135
137136
138137# --------------------------------------------------
139138def test_max_word_len ():
140139 """Test"""
141140
142- rv , out = getstatusoutput (f' { prg } -s 1 -x 10 { words } ' )
141+ rv , out = getstatusoutput (f"python { PRG } -s 1 -x 10 { WORDS } " )
143142 assert rv == 0
144- assert out .strip () == '\n ' .join ([
145- 'DicemanYardwandBoeberaKismetic' , 'CubiculumTilsitSnowcapSuer' ,
146- 'ProhasteHaddockChristmasyTenonitis'
147- ])
143+ assert out .strip () == "\n " .join (
144+ [
145+ "DicemanYardwandBoeberaKismetic" ,
146+ "CubiculumTilsitSnowcapSuer" ,
147+ "ProhasteHaddockChristmasyTenonitis" ,
148+ ]
149+ )
148150
149151
150152# --------------------------------------------------
151153def test_l33t ():
152154 """Test"""
153155
154- rv , out = getstatusoutput (f' { prg } -s 1 -l { words } ' )
156+ rv , out = getstatusoutput (f"python { PRG } -s 1 -l { WORDS } " )
155157 assert rv == 0
156- assert out .strip () == '\n ' .join ([
157- 'DUn1Teb0onloCiDef4T/' , 'Weg4TiTm@LuNPl4T54+1r3_' ,
158- 'iD3@Ncl1P5v1+14rrie+/'
159- ])
158+ assert out .strip () == "\n " .join (
159+ ["DUn1Teb0onloCiDef4T/" , "Weg4TiTm@LuNPl4T54+1r3_" , "iD3@Ncl1P5v1+14rrie+/" ]
160+ )
160161
161162
162163# --------------------------------------------------
163164def random_string ():
164165 """generate a random string"""
165166
166167 k = random .randint (5 , 10 )
167- return '' .join (random .choices (string .ascii_letters + string .digits , k = k ))
168+ return "" .join (random .choices (string .ascii_letters + string .digits , k = k ))
0 commit comments