@@ -132,6 +132,63 @@ def test_seed4_num3_input2():
132132 assert out .strip () == expected .strip ()
133133
134134
135+ # --------------------------------------------------
136+ def test_bad_tablefmt ():
137+ """Dies on bad --tablefmt"""
138+
139+ bad = 'badformat'
140+ rv , out = getstatusoutput (f'{ prg } -tf { bad } ' )
141+ assert rv != 0
142+ assert re .search (f"argument -tf/--tablefmt: invalid choice: '{ bad } '" , out )
143+
144+ # --------------------------------------------------
145+
146+
147+ def test_seed2_num8_tablefmt_plain ():
148+ """Runs OK, plain formatting"""
149+
150+ expected = """
151+ Exercise Reps
152+ Burpees 39
153+ Situps 42
154+ Crunches 29
155+ Pushups 68
156+ Plank 35
157+ Hand-stand pushups 18
158+ Pullups 30
159+ Lunges 32
160+ """
161+
162+ seed_flag = '-s' if random .choice ([0 , 1 ]) else '--seed'
163+ num_flag = '-n' if random .choice ([0 , 1 ]) else '--num'
164+ format_flag = '-tf' if random .choice ([0 , 1 ]) else '--tablefmt'
165+ cmd = f'{ prg } { num_flag } 8 { seed_flag } 2 -f { input1 } { format_flag } plain'
166+ rv , out = getstatusoutput (cmd )
167+ assert rv == 0
168+ assert out .strip () == expected .strip ()
169+
170+
171+ # --------------------------------------------------
172+ def test_seed4_num3_input2_tablefmt_github ():
173+ """Runs OK, github formatting"""
174+
175+ expected = """
176+ | Exercise | Reps |
177+ |-------------------|--------|
178+ | Hanging Chads | 86 |
179+ | Red Barchettas | 50 |
180+ | Squatting Chinups | 35 |
181+ """
182+
183+ seed_flag = '-s' if random .choice ([0 , 1 ]) else '--seed'
184+ num_flag = '-n' if random .choice ([0 , 1 ]) else '--num'
185+ format_flag = '-tf' if random .choice ([0 , 1 ]) else '--tablefmt'
186+ rv , out = getstatusoutput (
187+ f'{ prg } { num_flag } 3 { seed_flag } 4 -f { input2 } { format_flag } github' )
188+ assert rv == 0
189+ assert out .strip () == expected .strip ()
190+
191+
135192# --------------------------------------------------
136193def random_string ():
137194 """generate a random string"""
0 commit comments