File tree 2 files changed +37
-0
lines changed
2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,15 @@ def summary_passes(self):
458
458
self .write_sep ("_" , msg )
459
459
self ._outrep_summary (rep )
460
460
461
+ def print_teardown_sections (self , rep ):
462
+ for secname , content in rep .sections :
463
+ if 'teardown' in secname :
464
+ self ._tw .sep ('-' , secname )
465
+ if content [- 1 :] == "\n " :
466
+ content = content [:- 1 ]
467
+ self ._tw .line (content )
468
+
469
+
461
470
def summary_failures (self ):
462
471
if self .config .option .tbstyle != "no" :
463
472
reports = self .getreports ('failed' )
@@ -473,6 +482,9 @@ def summary_failures(self):
473
482
markup = {'red' : True , 'bold' : True }
474
483
self .write_sep ("_" , msg , ** markup )
475
484
self ._outrep_summary (rep )
485
+ for report in self .getreports ('' ):
486
+ if report .nodeid == rep .nodeid and report .when == 'teardown' :
487
+ self .print_teardown_sections (report )
476
488
477
489
def summary_errors (self ):
478
490
if self .config .option .tbstyle != "no" :
Original file line number Diff line number Diff line change @@ -370,6 +370,31 @@ def teardown_function(function):
370
370
"*1 failed*1 error*" ,
371
371
])
372
372
373
+ def test_setup_teardown_output_and_test_failure (self , testdir ):
374
+ """ Test for issue #442 """
375
+ testdir .makepyfile ("""
376
+ def setup_function(function):
377
+ print ("setup func")
378
+
379
+ def test_fail():
380
+ assert 0, "failingfunc"
381
+
382
+ def teardown_function(function):
383
+ print ("teardown func")
384
+ """ )
385
+ result = testdir .runpytest ()
386
+ result .stdout .fnmatch_lines ([
387
+ "*test_fail*" ,
388
+ "*def test_fail():" ,
389
+ "*failingfunc*" ,
390
+ "*Captured stdout setup*" ,
391
+ "*setup func*" ,
392
+ "*Captured stdout teardown*" ,
393
+ "*teardown func*" ,
394
+
395
+ "*1 failed*" ,
396
+ ])
397
+
373
398
class TestTerminalFunctional :
374
399
def test_deselected (self , testdir ):
375
400
testpath = testdir .makepyfile ("""
You can’t perform that action at this time.
0 commit comments