Merge pull request #976 from nicoddemus/ren-warnings-on-terminal

Rename "warnings" to "pytest-warnings" in terminal output
This commit is contained in:
Ronny Pfannschmidt 2015-09-01 07:56:42 +02:00
commit 7292212d5a
5 changed files with 15 additions and 7 deletions

View File

@ -83,6 +83,11 @@
- fix issue713: JUnit XML reports for doctest failures. - fix issue713: JUnit XML reports for doctest failures.
Thanks Punyashloka Biswal. Thanks Punyashloka Biswal.
- fix issue970: internal pytest warnings now appear as "pytest-warnings" in
the terminal instead of "warnings", so it is clear for users that those
warnings are from pytest and not from the builtin "warnings" module.
Thanks Bruno Oliveira.
- Include setup and teardown in junitxml test durations. - Include setup and teardown in junitxml test durations.
Thanks Janne Vanhala. Thanks Janne Vanhala.

View File

@ -326,7 +326,7 @@ def testdir(request, tmpdir_factory):
return Testdir(request, tmpdir_factory) return Testdir(request, tmpdir_factory)
rex_outcome = re.compile("(\d+) (\w+)") rex_outcome = re.compile("(\d+) ([\w-]+)")
class RunResult: class RunResult:
"""The result of running a command. """The result of running a command.

View File

@ -438,7 +438,7 @@ class TerminalReporter:
warnings = self.stats.get("warnings") warnings = self.stats.get("warnings")
if not warnings: if not warnings:
return return
self.write_sep("=", "warning summary") self.write_sep("=", "pytest-warning summary")
for w in warnings: for w in warnings:
self._tw.line("W%s %s %s" % (w.code, self._tw.line("W%s %s %s" % (w.code,
w.fslocation, w.message)) w.fslocation, w.message))
@ -527,6 +527,7 @@ def flatten(l):
def build_summary_stats_line(stats): def build_summary_stats_line(stats):
keys = ("failed passed skipped deselected " keys = ("failed passed skipped deselected "
"xfailed xpassed warnings error").split() "xfailed xpassed warnings error").split()
key_translation = {'warnings': 'pytest-warnings'}
unknown_key_seen = False unknown_key_seen = False
for key in stats.keys(): for key in stats.keys():
if key not in keys: if key not in keys:
@ -537,7 +538,8 @@ def build_summary_stats_line(stats):
for key in keys: for key in keys:
val = stats.get(key, None) val = stats.get(key, None)
if val: if val:
parts.append("%d %s" % (len(val), key)) key_name = key_translation.get(key, key)
parts.append("%d %s" % (len(val), key_name))
line = ", ".join(parts) line = ", ".join(parts)
if 'failed' in stats or 'error' in stats: if 'failed' in stats or 'error' in stats:

View File

@ -429,12 +429,12 @@ class TestWarning:
pass pass
""") """)
result = testdir.runpytest() result = testdir.runpytest()
assert result.parseoutcomes()["warnings"] > 0 assert result.parseoutcomes()["pytest-warnings"] > 0
assert "hello" not in result.stdout.str() assert "hello" not in result.stdout.str()
result = testdir.runpytest("-rw") result = testdir.runpytest("-rw")
result.stdout.fnmatch_lines(""" result.stdout.fnmatch_lines("""
===*warning summary*=== ===*pytest-warning summary*===
*WT1*test_warn_on_test_item*:5*hello* *WT1*test_warn_on_test_item*:5*hello*
""") """)

View File

@ -756,8 +756,9 @@ def test_terminal_summary(testdir):
("yellow", "1 weird", {"weird": (1,)}), ("yellow", "1 weird", {"weird": (1,)}),
("yellow", "1 passed, 1 weird", {"weird": (1,), "passed": (1,)}), ("yellow", "1 passed, 1 weird", {"weird": (1,), "passed": (1,)}),
("yellow", "1 warnings", {"warnings": (1,)}), ("yellow", "1 pytest-warnings", {"warnings": (1,)}),
("yellow", "1 passed, 1 warnings", {"warnings": (1,), "passed": (1,)}), ("yellow", "1 passed, 1 pytest-warnings", {"warnings": (1,),
"passed": (1,)}),
("green", "5 passed", {"passed": (1,2,3,4,5)}), ("green", "5 passed", {"passed": (1,2,3,4,5)}),