diff options
author | Mathieu Clabaut <mathieu@clabaut.net> | 2016-10-30 09:46:08 +0100 |
---|---|---|
committer | Mathieu Clabaut <mathieu@clabaut.net> | 2016-10-30 09:52:46 +0100 |
commit | 6f93ffb5d4de88fe6ad57d3195938d538988e45b (patch) | |
tree | 8383501058587768da2cfe7c1a6b84418e1636a4 /_pytest | |
parent | 35d154f58058573ccfde431e558f00d2420c2530 (diff) | |
download | pytest-6f93ffb5d4de88fe6ad57d3195938d538988e45b.tar.gz |
Report teardown output on test failure
Until now, teardown stdout/stderr output was not reported upon test failure.
However such output is sometime necessary to understand the failure.
fix #442
Diffstat (limited to '_pytest')
-rw-r--r-- | _pytest/terminal.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/_pytest/terminal.py b/_pytest/terminal.py index fdbe4ec36..16bf75733 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -458,6 +458,15 @@ class TerminalReporter: self.write_sep("_", msg) self._outrep_summary(rep) + def print_teardown_sections(self, rep): + for secname, content in rep.sections: + if 'teardown' in secname: + self._tw.sep('-', secname) + if content[-1:] == "\n": + content = content[:-1] + self._tw.line(content) + + def summary_failures(self): if self.config.option.tbstyle != "no": reports = self.getreports('failed') @@ -473,6 +482,9 @@ class TerminalReporter: markup = {'red': True, 'bold': True} self.write_sep("_", msg, **markup) self._outrep_summary(rep) + for report in self.getreports(''): + if report.nodeid == rep.nodeid and report.when == 'teardown': + self.print_teardown_sections(report) def summary_errors(self): if self.config.option.tbstyle != "no": |