terminal/reports: add/use _get_verbose_word method

This commit is contained in:
Daniel Hahler 2019-04-15 07:23:40 +02:00
parent 19035f4b55
commit 9374114370
2 changed files with 10 additions and 10 deletions

View File

@ -148,6 +148,12 @@ class BaseReport(object):
fspath, lineno, domain = self.location
return domain
def _get_verbose_word(self, config):
_category, _short, verbose = config.hook.pytest_report_teststatus(
report=self, config=config
)
return verbose
def _to_json(self):
"""
This was originally the serialize_report() function from xdist (ca03269).

View File

@ -888,14 +888,14 @@ class TerminalReporter(object):
def show_simple(stat, lines):
failed = self.stats.get(stat, [])
for rep in failed:
verbose_word = _get_report_str(self.config, rep)
verbose_word = rep._get_verbose_word(self.config)
pos = _get_pos(self.config, rep)
lines.append("%s %s" % (verbose_word, pos))
def show_xfailed(lines):
xfailed = self.stats.get("xfailed", [])
for rep in xfailed:
verbose_word = _get_report_str(self.config, rep)
verbose_word = rep._get_verbose_word(self.config)
pos = _get_pos(self.config, rep)
lines.append("%s %s" % (verbose_word, pos))
reason = rep.wasxfail
@ -905,7 +905,7 @@ class TerminalReporter(object):
def show_xpassed(lines):
xpassed = self.stats.get("xpassed", [])
for rep in xpassed:
verbose_word = _get_report_str(self.config, rep)
verbose_word = rep._get_verbose_word(self.config)
pos = _get_pos(self.config, rep)
reason = rep.wasxfail
lines.append("%s %s %s" % (verbose_word, pos, reason))
@ -915,7 +915,7 @@ class TerminalReporter(object):
fskips = _folded_skips(skipped) if skipped else []
if not fskips:
return
verbose_word = _get_report_str(self.config, report=skipped[0])
verbose_word = skipped[0]._get_verbose_word(self.config)
for num, fspath, lineno, reason in fskips:
if reason.startswith("Skipped: "):
reason = reason[9:]
@ -927,12 +927,6 @@ class TerminalReporter(object):
else:
lines.append("%s [%d] %s: %s" % (verbose_word, num, fspath, reason))
def _get_report_str(config, report):
_category, _short, verbose = config.hook.pytest_report_teststatus(
report=report, config=config
)
return verbose
def _get_pos(config, rep):
nodeid = config.cwd_relative_nodeid(rep.nodeid)
return nodeid