Add -rp and -rP options to report passing tests.
-rP is an alternative to `-s` for viewing the output of passing tests. This causes the captured stdout/stderr of passing tests to be output in the same way as that of failing tests. -rp adds a simple one-line-per-test summary for passing tests. Neither option is included by -ra. Additional changes to `pytest_capturelog` and `pytest_catchlog` are needed for this option to also output captured logs: They must be changed to use `rep.sections.add` instead of `rep.longrepr.addsection`, and to add these additional sections even if the test passes, since passing tests don't seem to have a `longrepr` at report time.
This commit is contained in:
parent
84eacf3e3c
commit
fbac936596
|
@ -177,9 +177,13 @@ class BaseReport(object):
|
|||
self.__dict__.update(kw)
|
||||
|
||||
def toterminal(self, out):
|
||||
longrepr = self.longrepr
|
||||
if hasattr(self, 'node'):
|
||||
out.line(getslaveinfoline(self.node))
|
||||
|
||||
longrepr = self.longrepr
|
||||
if longrepr is None:
|
||||
return
|
||||
|
||||
if hasattr(longrepr, 'toterminal'):
|
||||
longrepr.toterminal(out)
|
||||
else:
|
||||
|
|
|
@ -252,6 +252,9 @@ def pytest_terminal_summary(terminalreporter):
|
|||
show_skipped(terminalreporter, lines)
|
||||
elif char == "E":
|
||||
show_simple(terminalreporter, lines, 'error', "ERROR %s")
|
||||
elif char == 'p':
|
||||
show_simple(terminalreporter, lines, 'passed', "PASSED %s")
|
||||
|
||||
if lines:
|
||||
tr._tw.sep("=", "short test summary info")
|
||||
for line in lines:
|
||||
|
|
|
@ -22,7 +22,8 @@ def pytest_addoption(parser):
|
|||
group._addoption('-r',
|
||||
action="store", dest="reportchars", default=None, metavar="chars",
|
||||
help="show extra test summary info as specified by chars (f)ailed, "
|
||||
"(E)error, (s)skipped, (x)failed, (X)passed (w)pytest-warnings (a)all.")
|
||||
"(E)error, (s)skipped, (x)failed, (X)passed (w)pytest-warnings "
|
||||
"(p)passed, (P)passed with output, (a)all except pP.")
|
||||
group._addoption('-l', '--showlocals',
|
||||
action="store_true", dest="showlocals", default=False,
|
||||
help="show locals in tracebacks (disabled by default).")
|
||||
|
@ -367,10 +368,12 @@ class TerminalReporter:
|
|||
self.summary_errors()
|
||||
self.summary_failures()
|
||||
self.summary_warnings()
|
||||
self.summary_passes()
|
||||
self.config.hook.pytest_terminal_summary(terminalreporter=self)
|
||||
if exitstatus == EXIT_INTERRUPTED:
|
||||
self._report_keyboardinterrupt()
|
||||
del self._keyboardinterrupt_memo
|
||||
|
||||
self.summary_deselected()
|
||||
self.summary_stats()
|
||||
|
||||
|
@ -446,6 +449,18 @@ class TerminalReporter:
|
|||
self._tw.line("W%s %s %s" % (w.code,
|
||||
w.fslocation, w.message))
|
||||
|
||||
def summary_passes(self):
|
||||
if self.config.option.tbstyle != "no":
|
||||
if self.hasopt("P"):
|
||||
reports = self.getreports('passed')
|
||||
if not reports:
|
||||
return
|
||||
self.write_sep("=", "PASSES")
|
||||
for rep in reports:
|
||||
msg = self._getfailureheadline(rep)
|
||||
self.write_sep("_", msg)
|
||||
self._outrep_summary(rep)
|
||||
|
||||
def summary_failures(self):
|
||||
if self.config.option.tbstyle != "no":
|
||||
reports = self.getreports('failed')
|
||||
|
|
Loading…
Reference in New Issue