diff --git a/src/_pytest/terminal.py b/src/_pytest/terminal.py index e88545eca..d1ee701e8 100644 --- a/src/_pytest/terminal.py +++ b/src/_pytest/terminal.py @@ -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"), diff --git a/testing/test_terminal.py b/testing/test_terminal.py index fab13b07e..2d875a64c 100644 --- a/testing/test_terminal.py +++ b/testing/test_terminal.py @@ -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):