@@ -33,6 +33,11 @@ def __init__(self):
3333 # used by --junit-xml
3434 self .testsuite_xml : list [str ] = []
3535
36+ def is_all_good (self ):
37+ return (not self .bad
38+ and not self .skipped
39+ and not self .interrupted )
40+
3641 def get_executed (self ):
3742 return (set (self .good ) | set (self .bad ) | set (self .skipped )
3843 | set (self .resource_denied ) | set (self .env_changed )
@@ -164,61 +169,47 @@ def write_junit(self, filename: StrPath):
164169 f .write (s )
165170
166171 def display_result (self , tests : TestTuple , quiet : bool , print_slowest : bool ):
167- if self .interrupted :
168- print ("Test suite interrupted by signal SIGINT." )
169-
170172 omitted = set (tests ) - self .get_executed ()
171173 if omitted :
172174 print ()
173175 print (count (len (omitted ), "test" ), "omitted:" )
174176 printlist (omitted )
175177
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-
185178 if print_slowest :
186179 self .test_times .sort (reverse = True )
187180 print ()
188181 print ("10 slowest tests:" )
189182 for test_time , test in self .test_times [:10 ]:
190183 print ("- %s: %s" % (test , format_duration (test_time )))
191184
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 )
212201
213- if self .rerun :
202+ if self .good and not quiet :
214203 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 )
217209
218- if self .run_no_tests :
210+ if self .interrupted :
219211 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." )
222213
223214 def display_summary (self , first_runtests : RunTests , filtered : bool ):
224215 # Total tests
0 commit comments