This commit is contained in:
Daniel Hahler 2019-04-07 20:04:31 +02:00
parent d8d835c1f5
commit 2662c400ba
1 changed files with 33 additions and 41 deletions

View File

@ -880,54 +880,46 @@ class TerminalReporter(object):
return return
def show_simple(stat, lines): def show_simple(stat, lines):
failed = self.stats.get(stat) failed = self.stats.get(stat, [])
if failed: for rep in failed:
config = self.config verbose_word = _get_report_str(self.config, rep)
for rep in failed: pos = _get_pos(self.config, rep)
verbose_word = _get_report_str(config, rep) lines.append("%s %s" % (verbose_word, pos))
pos = _get_pos(config, rep)
lines.append("%s %s" % (verbose_word, pos))
def show_xfailed(lines): def show_xfailed(lines):
xfailed = self.stats.get("xfailed") xfailed = self.stats.get("xfailed", [])
if xfailed: for rep in xfailed:
config = self.config verbose_word = _get_report_str(self.config, rep)
for rep in xfailed: pos = _get_pos(self.config, rep)
verbose_word = _get_report_str(config, rep) lines.append("%s %s" % (verbose_word, pos))
pos = _get_pos(config, rep) reason = rep.wasxfail
lines.append("%s %s" % (verbose_word, pos)) if reason:
reason = rep.wasxfail lines.append(" " + str(reason))
if reason:
lines.append(" " + str(reason))
def show_xpassed(lines): def show_xpassed(lines):
xpassed = self.stats.get("xpassed") xpassed = self.stats.get("xpassed", [])
if xpassed: for rep in xpassed:
config = self.config verbose_word = _get_report_str(self.config, rep)
for rep in xpassed: pos = _get_pos(self.config, rep)
verbose_word = _get_report_str(config, rep) reason = rep.wasxfail
pos = _get_pos(config, rep) lines.append("%s %s %s" % (verbose_word, pos, reason))
reason = rep.wasxfail
lines.append("%s %s %s" % (verbose_word, pos, reason))
def show_skipped(lines): def show_skipped(lines):
skipped = self.stats.get("skipped", []) skipped = self.stats.get("skipped", [])
if skipped: fskips = _folded_skips(skipped) if skipped else []
fskips = _folded_skips(skipped) if not fskips:
if fskips: return
verbose_word = _get_report_str(self.config, report=skipped[0]) verbose_word = _get_report_str(self.config, report=skipped[0])
for num, fspath, lineno, reason in fskips: for num, fspath, lineno, reason in fskips:
if reason.startswith("Skipped: "): if reason.startswith("Skipped: "):
reason = reason[9:] reason = reason[9:]
if lineno is not None: if lineno is not None:
lines.append( lines.append(
"%s [%d] %s:%d: %s" "%s [%d] %s:%d: %s"
% (verbose_word, num, fspath, lineno + 1, reason) % (verbose_word, num, fspath, lineno + 1, reason)
) )
else: else:
lines.append( lines.append("%s [%d] %s: %s" % (verbose_word, num, fspath, reason))
"%s [%d] %s: %s" % (verbose_word, num, fspath, reason)
)
def _get_report_str(config, report): def _get_report_str(config, report):
_category, _short, verbose = config.hook.pytest_report_teststatus( _category, _short, verbose = config.hook.pytest_report_teststatus(