Make -r letters "f" and "F" aliases

As far as the output is concerned, they are both identical so it doesn't
make sense to have both.

setup, teardown, and collect failures are already reported as "errors", "E".
This commit is contained in:
Bruno Oliveira 2019-12-12 07:41:23 -03:00
parent cbb2f9541b
commit 59067ad33d
2 changed files with 25 additions and 10 deletions

View File

@ -173,6 +173,9 @@ def getreportopt(config: Config) -> str:
elif config.option.disable_warnings and "w" in reportchars:
reportchars = reportchars.replace("w", "")
for char in reportchars:
# f and F are aliases
if char == "F":
char = "f"
if char == "a":
reportopts = "sxXwEf"
elif char == "A":
@ -185,19 +188,16 @@ def getreportopt(config: Config) -> str:
@pytest.hookimpl(trylast=True) # after _pytest.runner
def pytest_report_teststatus(report: TestReport) -> Tuple[str, str, str]:
letter = "F"
if report.passed:
letter = "."
elif report.skipped:
letter = "s"
elif report.failed:
letter = "F"
if report.when != "call":
letter = "f"
# Report failed CollectReports as "error" (in line with pytest_collectreport).
outcome = report.outcome
if report.when == "collect" and outcome == "failed":
if report.when in ("collect", "setup", "teardown") and outcome == "failed":
outcome = "error"
letter = "E"
return outcome, letter, outcome.upper()
@ -988,7 +988,6 @@ class TerminalReporter:
"x": show_xfailed,
"X": show_xpassed,
"f": partial(show_simple, "failed"),
"F": partial(show_simple, "failed"),
"s": show_skipped,
"S": show_skipped,
"p": partial(show_simple, "passed"),

View File

@ -754,6 +754,18 @@ class TestTerminalFunctional:
result = testdir.runpytest(*params)
result.stdout.fnmatch_lines(["collected 3 items", "hello from hook: 3 items"])
def test_summary_f_alias(self, testdir):
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_fail_extra_reporting(testdir, monkeypatch):
monkeypatch.setenv("COLUMNS", "80")
@ -1685,12 +1697,16 @@ class TestProgressWithTeardown:
testdir.makepyfile(
"""
def test_foo(fail_teardown):
assert False
assert 0
"""
)
output = testdir.runpytest()
output = testdir.runpytest("-rfE")
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):