Merge pull request #5126 from blueyed/report-get_verbose_word

terminal/reports: use get_verbose_word method
This commit is contained in:
Daniel Hahler 2019-04-17 14:43:54 +02:00 committed by GitHub
commit 2b11b2c093
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -148,6 +148,12 @@ class BaseReport(object):
fspath, lineno, domain = self.location fspath, lineno, domain = self.location
return domain 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): def _to_json(self):
""" """
This was originally the serialize_report() function from xdist (ca03269). This was originally the serialize_report() function from xdist (ca03269).

View File

@ -890,14 +890,14 @@ class TerminalReporter(object):
def show_simple(stat, lines): def show_simple(stat, lines):
failed = self.stats.get(stat, []) failed = self.stats.get(stat, [])
for rep in failed: 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) pos = _get_pos(self.config, rep)
lines.append("%s %s" % (verbose_word, pos)) 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", [])
for rep in 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) pos = _get_pos(self.config, rep)
lines.append("%s %s" % (verbose_word, pos)) lines.append("%s %s" % (verbose_word, pos))
reason = rep.wasxfail reason = rep.wasxfail
@ -907,7 +907,7 @@ class TerminalReporter(object):
def show_xpassed(lines): def show_xpassed(lines):
xpassed = self.stats.get("xpassed", []) xpassed = self.stats.get("xpassed", [])
for rep in 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) pos = _get_pos(self.config, rep)
reason = rep.wasxfail reason = rep.wasxfail
lines.append("%s %s %s" % (verbose_word, pos, reason)) lines.append("%s %s %s" % (verbose_word, pos, reason))
@ -917,7 +917,7 @@ class TerminalReporter(object):
fskips = _folded_skips(skipped) if skipped else [] fskips = _folded_skips(skipped) if skipped else []
if not fskips: if not fskips:
return 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: for num, fspath, lineno, reason in fskips:
if reason.startswith("Skipped: "): if reason.startswith("Skipped: "):
reason = reason[9:] reason = reason[9:]
@ -929,12 +929,6 @@ class TerminalReporter(object):
else: else:
lines.append("%s [%d] %s: %s" % (verbose_word, num, fspath, reason)) 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): def _get_pos(config, rep):
nodeid = config.cwd_relative_nodeid(rep.nodeid) nodeid = config.cwd_relative_nodeid(rep.nodeid)
return nodeid return nodeid