terminal: revisit summary_failures

- get the list of reports for teardown sections only once
- do not check option in loop
This commit is contained in:
Daniel Hahler 2019-04-15 05:48:35 +02:00
parent 19035f4b55
commit 20c624efcf
1 changed files with 11 additions and 6 deletions

View File

@ -828,17 +828,22 @@ class TerminalReporter(object):
if not reports: if not reports:
return return
self.write_sep("=", "FAILURES") self.write_sep("=", "FAILURES")
for rep in reports: if self.config.option.tbstyle == "line":
if self.config.option.tbstyle == "line": for rep in reports:
line = self._getcrashline(rep) line = self._getcrashline(rep)
self.write_line(line) self.write_line(line)
else: else:
teardown_sections = {}
for report in self.getreports(""):
if report.when == "teardown":
teardown_sections.setdefault(report.nodeid, []).append(report)
for rep in reports:
msg = self._getfailureheadline(rep) msg = self._getfailureheadline(rep)
self.write_sep("_", msg, red=True, bold=True) self.write_sep("_", msg, red=True, bold=True)
self._outrep_summary(rep) self._outrep_summary(rep)
for report in self.getreports(""): for report in teardown_sections.get(rep.nodeid, []):
if report.nodeid == rep.nodeid and report.when == "teardown": self.print_teardown_sections(report)
self.print_teardown_sections(report)
def summary_errors(self): def summary_errors(self):
if self.config.option.tbstyle != "no": if self.config.option.tbstyle != "no":