@@ -172,7 +172,7 @@ def print_report(filenames, filter, filter_env, show_output, markdown=False):
172172 ** stats ,
173173 }
174174 )
175- print_table ( table , markdown = markdown )
175+ print ( format_table ( table , markdown = markdown ) )
176176
177177 interesting_envs = set ()
178178 for env , stats in per_env_stats .items ():
@@ -212,7 +212,11 @@ def print_report(filenames, filter, filter_env, show_output, markdown=False):
212212 ** items ,
213213 }
214214 )
215- print_table (table , markdown = markdown )
215+ table_txt = format_table (table , markdown = markdown )
216+ if len (table ) > 5 :
217+ table_txt = wrap_in_details (table_txt , f"{ len (table )} failing tests:" )
218+ if table_txt :
219+ print (table_txt )
216220
217221 if show_output :
218222 for testname , stats in simplified_results .items ():
@@ -228,7 +232,7 @@ def print_report(filenames, filter, filter_env, show_output, markdown=False):
228232 print ()
229233
230234
231- def print_table (table , columns = None , markdown = False ):
235+ def format_table (table , columns = None , markdown = False ):
232236 """
233237 Pretty-print a list-of-dicts as an aligned text table.
234238
@@ -238,7 +242,7 @@ def print_table(table, columns=None, markdown=False):
238242 markdown (bool): whether to output in markdown format
239243 """
240244 if not table :
241- return
245+ return []
242246
243247 if columns is None :
244248 columns = []
@@ -256,21 +260,30 @@ def print_table(table, columns=None, markdown=False):
256260 for i , col in enumerate (columns ):
257261 widths [i ] = max (widths [i ], len (str (row .get (col , "" ))))
258262
263+ result = []
264+ write = result .append
265+
259266 if markdown :
260267 # Header
261- print ("| " + " | " .join (str (col ).ljust (w ) for col , w in zip (columns , widths )) + " |" )
268+ write ("| " + " | " .join (str (col ).ljust (w ) for col , w in zip (columns , widths )) + " |" )
262269 # Separator
263- print ("| " + " | " .join ("-" * w for w in widths ) + " |" )
270+ write ("| " + " | " .join ("-" * w for w in widths ) + " |" )
264271 # Data rows
265272 for row in table :
266- print ("| " + " | " .join (str (row .get (col , "" )).ljust (w ) for col , w in zip (columns , widths )) + " |" )
273+ write ("| " + " | " .join (str (row .get (col , "" )).ljust (w ) for col , w in zip (columns , widths )) + " |" )
267274 else :
268275 fmt = lambda cells : " " .join (str (cell ).ljust (w ) for cell , w in zip (cells , widths ))
269- print (fmt (columns ))
276+ write (fmt (columns ))
270277 for ind , row in enumerate (table ):
271- print (fmt ([row .get (col , "" ) for col in columns ]))
278+ write (fmt ([row .get (col , "" ) for col in columns ]))
279+
280+ write ("" )
281+
282+ return "\n " .join (result )
283+
272284
273- print ()
285+ def wrap_in_details (txt , summary ):
286+ return f"<details><summary>{ summary } </summary>\n \n { txt } \n \n </details>"
274287
275288
276289def main ():
0 commit comments