@@ -33,6 +33,11 @@ def __init__(self):
33
33
# used by --junit-xml
34
34
self .testsuite_xml : list [str ] = []
35
35
36
+ def is_all_good (self ):
37
+ return (not self .bad
38
+ and not self .skipped
39
+ and not self .interrupted )
40
+
36
41
def get_executed (self ):
37
42
return (set (self .good ) | set (self .bad ) | set (self .skipped )
38
43
| set (self .resource_denied ) | set (self .env_changed )
@@ -164,61 +169,47 @@ def write_junit(self, filename: StrPath):
164
169
f .write (s )
165
170
166
171
def display_result (self , tests : TestTuple , quiet : bool , print_slowest : bool ):
167
- if self .interrupted :
168
- print ("Test suite interrupted by signal SIGINT." )
169
-
170
172
omitted = set (tests ) - self .get_executed ()
171
173
if omitted :
172
174
print ()
173
175
print (count (len (omitted ), "test" ), "omitted:" )
174
176
printlist (omitted )
175
177
176
- if self .good and not quiet :
177
- print ()
178
- if (not self .bad
179
- and not self .skipped
180
- and not self .interrupted
181
- and len (self .good ) > 1 ):
182
- print ("All" , end = ' ' )
183
- print (count (len (self .good ), "test" ), "OK." )
184
-
185
178
if print_slowest :
186
179
self .test_times .sort (reverse = True )
187
180
print ()
188
181
print ("10 slowest tests:" )
189
182
for test_time , test in self .test_times [:10 ]:
190
183
print ("- %s: %s" % (test , format_duration (test_time )))
191
184
192
- if self .bad :
193
- print ()
194
- print (count (len (self .bad ), "test" ), "failed:" )
195
- printlist (self .bad )
196
-
197
- if self .env_changed :
198
- print ()
199
- print ("{} altered the execution environment:" .format (
200
- count (len (self .env_changed ), "test" )))
201
- printlist (self .env_changed )
202
-
203
- if self .skipped and not quiet :
204
- print ()
205
- print (count (len (self .skipped ), "test" ), "skipped:" )
206
- printlist (self .skipped )
207
-
208
- if self .resource_denied and not quiet :
209
- print ()
210
- print (count (len (self .resource_denied ), "test" ), "skipped (resource denied):" )
211
- printlist (self .resource_denied )
185
+ all_tests = [
186
+ (self .bad , "test" , "{} failed:" ),
187
+ (self .env_changed , "test" , "{} altered the execution environment (env changed):" ),
188
+ ]
189
+ if not quiet :
190
+ all_tests .append ((self .skipped , "test" , "{} skipped:" ))
191
+ all_tests .append ((self .resource_denied , "test" , "{} skipped (resource denied):" ))
192
+ all_tests .append ((self .rerun , "re-run test" , "{}:" ))
193
+ all_tests .append ((self .run_no_tests , "test" , "{} run no tests:" ))
194
+
195
+ for tests_list , count_text , title_format in all_tests :
196
+ if tests_list :
197
+ print ()
198
+ count_text = count (len (tests_list ), count_text )
199
+ print (title_format .format (count_text ))
200
+ printlist (tests_list )
212
201
213
- if self .rerun :
202
+ if self .good and not quiet :
214
203
print ()
215
- print ("%s:" % count (len (self .rerun ), "re-run test" ))
216
- printlist (self .rerun )
204
+ text = count (len (self .good ), "test" )
205
+ text = f"{ text } OK."
206
+ if (self .is_all_good () and len (self .good ) > 1 ):
207
+ text = f"All { text } "
208
+ print (text )
217
209
218
- if self .run_no_tests :
210
+ if self .interrupted :
219
211
print ()
220
- print (count (len (self .run_no_tests ), "test" ), "run no tests:" )
221
- printlist (self .run_no_tests )
212
+ print ("Test suite interrupted by signal SIGINT." )
222
213
223
214
def display_summary (self , first_runtests : RunTests , filtered : bool ):
224
215
# Total tests
0 commit comments