@@ -302,36 +302,44 @@ def run_suite(c, test_result):
302
302
set_up = getattr (o , "setUp" , lambda : None )
303
303
tear_down = getattr (o , "tearDown" , lambda : None )
304
304
exceptions = []
305
+
306
+ def run_one (m ):
307
+ print ("%s (%s) ..." % (name , c .__qualname__ ), end = "" )
308
+ set_up ()
309
+ try :
310
+ test_result .testsRun += 1
311
+ m ()
312
+ print (" ok" )
313
+ except SkipTest as e :
314
+ print (" skipped:" , e .args [0 ])
315
+ test_result .skippedNum += 1
316
+ except Exception as ex :
317
+ ex_str = capture_exc (ex )
318
+ if isinstance (ex , AssertionError ):
319
+ test_result .failuresNum += 1
320
+ test_result .failures .append (((name , c ), ex_str ))
321
+ print (" FAIL" )
322
+ else :
323
+ test_result .errorsNum += 1
324
+ test_result .errors .append (((name , c ), ex_str ))
325
+ print (" ERROR" )
326
+ # Uncomment to investigate failure in detail
327
+ # raise
328
+ finally :
329
+ tear_down ()
330
+ o .doCleanups ()
331
+
332
+ if hasattr (o , "runTest" ):
333
+ name = str (o )
334
+ run_one (o .runTest )
335
+ return
336
+
305
337
for name in dir (o ):
306
338
if name .startswith ("test" ):
307
339
m = getattr (o , name )
308
340
if not callable (m ):
309
341
continue
310
- print ("%s (%s) ..." % (name , c .__qualname__ ), end = "" )
311
- set_up ()
312
- try :
313
- test_result .testsRun += 1
314
- m ()
315
- print (" ok" )
316
- except SkipTest as e :
317
- print (" skipped:" , e .args [0 ])
318
- test_result .skippedNum += 1
319
- except Exception as ex :
320
- ex_str = capture_exc (ex )
321
- if isinstance (ex , AssertionError ):
322
- test_result .failuresNum += 1
323
- test_result .failures .append (((name , c ), ex_str ))
324
- print (" FAIL" )
325
- else :
326
- test_result .errorsNum += 1
327
- test_result .errors .append (((name , c ), ex_str ))
328
- print (" ERROR" )
329
- # Uncomment to investigate failure in detail
330
- # raise
331
- continue
332
- finally :
333
- tear_down ()
334
- o .doCleanups ()
342
+ run_one (m )
335
343
return exceptions
336
344
337
345
0 commit comments