File tree 4 files changed +42
-1
lines changed
4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ Markus Unterwaditzer
90
90
Martijn Faassen
91
91
Martin K. Scherer
92
92
Martin Prusse
93
+ Mathieu Clabaut
93
94
Matt Bachmann
94
95
Matt Williams
95
96
Matthias Hafner
Original file line number Diff line number Diff line change 17
17
or implicitly as a plugin (`#2005 `_).
18
18
Thanks `@RonnyPfannschmidt `_ for the report and `@nicoddemus `_ for the PR.
19
19
20
- *
20
+ * Report teardown output on test failure (`#442 `_).
21
+ Thanks `@matclab `_ or the PR.
21
22
22
23
*
23
24
26
27
27
28
.. _@cwitty : https://github.com/cwitty
28
29
.. _@okulynyak : https://github.com/okulynyak
30
+ .. _@matclab : https://github.com/matclab
29
31
32
+ .. _#442 : https://github.com/pytest-dev/pytest/issues/442
30
33
.. _#1976 : https://github.com/pytest-dev/pytest/issues/1976
31
34
.. _#1998 : https://github.com/pytest-dev/pytest/issues/1998
32
35
.. _#2004 : https://github.com/pytest-dev/pytest/issues/2004
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