Make 'S' and 'F' aliases to 's' and 'f' respectively (#6337)
(cherry picked from commit ecd1e43afb
)
This commit is contained in:
parent
d5843f89d3
commit
049f5b513a
|
@ -0,0 +1,3 @@
|
||||||
|
Fix summary entries appearing twice when ``f/F`` and ``s/S`` report chars were used at the same time in the ``-r`` command-line option (for example ``-rFf``).
|
||||||
|
|
||||||
|
The upper case variants were never documented and the preferred form should be the lower case.
|
|
@ -166,7 +166,11 @@ def getreportopt(config):
|
||||||
reportchars += "w"
|
reportchars += "w"
|
||||||
elif config.option.disable_warnings and "w" in reportchars:
|
elif config.option.disable_warnings and "w" in reportchars:
|
||||||
reportchars = reportchars.replace("w", "")
|
reportchars = reportchars.replace("w", "")
|
||||||
|
aliases = {"F", "S"}
|
||||||
for char in reportchars:
|
for char in reportchars:
|
||||||
|
# handle old aliases
|
||||||
|
if char in aliases:
|
||||||
|
char = char.lower()
|
||||||
if char == "a":
|
if char == "a":
|
||||||
reportopts = "sxXwEf"
|
reportopts = "sxXwEf"
|
||||||
elif char == "A":
|
elif char == "A":
|
||||||
|
@ -179,15 +183,18 @@ def getreportopt(config):
|
||||||
|
|
||||||
@pytest.hookimpl(trylast=True) # after _pytest.runner
|
@pytest.hookimpl(trylast=True) # after _pytest.runner
|
||||||
def pytest_report_teststatus(report):
|
def pytest_report_teststatus(report):
|
||||||
|
letter = "F"
|
||||||
if report.passed:
|
if report.passed:
|
||||||
letter = "."
|
letter = "."
|
||||||
elif report.skipped:
|
elif report.skipped:
|
||||||
letter = "s"
|
letter = "s"
|
||||||
elif report.failed:
|
|
||||||
letter = "F"
|
outcome = report.outcome
|
||||||
if report.when != "call":
|
if report.when in ("collect", "setup", "teardown") and outcome == "failed":
|
||||||
letter = "f"
|
outcome = "error"
|
||||||
return report.outcome, letter, report.outcome.upper()
|
letter = "E"
|
||||||
|
|
||||||
|
return outcome, letter, outcome.upper()
|
||||||
|
|
||||||
|
|
||||||
@attr.s
|
@attr.s
|
||||||
|
@ -935,9 +942,7 @@ class TerminalReporter(object):
|
||||||
"x": show_xfailed,
|
"x": show_xfailed,
|
||||||
"X": show_xpassed,
|
"X": show_xpassed,
|
||||||
"f": partial(show_simple, "failed"),
|
"f": partial(show_simple, "failed"),
|
||||||
"F": partial(show_simple, "failed"),
|
|
||||||
"s": show_skipped,
|
"s": show_skipped,
|
||||||
"S": show_skipped,
|
|
||||||
"p": partial(show_simple, "passed"),
|
"p": partial(show_simple, "passed"),
|
||||||
"E": partial(show_simple, "error"),
|
"E": partial(show_simple, "error"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -759,6 +759,35 @@ class TestTerminalFunctional(object):
|
||||||
result = testdir.runpytest(*params)
|
result = testdir.runpytest(*params)
|
||||||
result.stdout.fnmatch_lines(["collected 3 items", "hello from hook: 3 items"])
|
result.stdout.fnmatch_lines(["collected 3 items", "hello from hook: 3 items"])
|
||||||
|
|
||||||
|
def test_summary_f_alias(self, testdir):
|
||||||
|
"""Test that 'f' and 'F' report chars are aliases and don't show up twice in the summary (#6334)"""
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
def test():
|
||||||
|
assert False
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest("-rfF")
|
||||||
|
expected = "FAILED test_summary_f_alias.py::test - assert False"
|
||||||
|
result.stdout.fnmatch_lines([expected])
|
||||||
|
assert result.stdout.lines.count(expected) == 1
|
||||||
|
|
||||||
|
def test_summary_s_alias(self, testdir):
|
||||||
|
"""Test that 's' and 'S' report chars are aliases and don't show up twice in the summary"""
|
||||||
|
testdir.makepyfile(
|
||||||
|
"""
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
@pytest.mark.skip
|
||||||
|
def test():
|
||||||
|
pass
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
result = testdir.runpytest("-rsS")
|
||||||
|
expected = "SKIPPED [1] test_summary_s_alias.py:3: unconditional skip"
|
||||||
|
result.stdout.fnmatch_lines([expected])
|
||||||
|
assert result.stdout.lines.count(expected) == 1
|
||||||
|
|
||||||
|
|
||||||
def test_fail_extra_reporting(testdir, monkeypatch):
|
def test_fail_extra_reporting(testdir, monkeypatch):
|
||||||
monkeypatch.setenv("COLUMNS", "80")
|
monkeypatch.setenv("COLUMNS", "80")
|
||||||
|
@ -1551,12 +1580,16 @@ class TestProgressWithTeardown(object):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
"""
|
"""
|
||||||
def test_foo(fail_teardown):
|
def test_foo(fail_teardown):
|
||||||
assert False
|
assert 0
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
output = testdir.runpytest()
|
output = testdir.runpytest("-rfE")
|
||||||
output.stdout.re_match_lines(
|
output.stdout.re_match_lines(
|
||||||
[r"test_teardown_with_test_also_failing.py FE\s+\[100%\]"]
|
[
|
||||||
|
r"test_teardown_with_test_also_failing.py FE\s+\[100%\]",
|
||||||
|
"FAILED test_teardown_with_test_also_failing.py::test_foo - assert 0",
|
||||||
|
"ERROR test_teardown_with_test_also_failing.py::test_foo - assert False",
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_teardown_many(self, testdir, many_files):
|
def test_teardown_many(self, testdir, many_files):
|
||||||
|
|
Loading…
Reference in New Issue