Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminal: report collection errors as "ERROR" in short summary #6059

Merged
merged 1 commit into from
Nov 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/6059.improvement.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Collection errors are reported as errors (and not failures like before) in the terminal's short test summary.
8 changes: 7 additions & 1 deletion src/_pytest/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,13 @@ def pytest_report_teststatus(report):
letter = "F"
if report.when != "call":
letter = "f"
return report.outcome, letter, report.outcome.upper()

# Report failed CollectReports as "error" (in line with pytest_collectreport).
outcome = report.outcome
if report.when == "collect" and outcome == "failed":
outcome = "error"

return outcome, letter, outcome.upper()


@attr.s
Expand Down
17 changes: 17 additions & 0 deletions testing/test_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1776,3 +1776,20 @@ def test_format_session_duration(seconds, expected):
from _pytest.terminal import format_session_duration

assert format_session_duration(seconds) == expected


def test_collecterror(testdir):
p1 = testdir.makepyfile("raise SyntaxError()")
result = testdir.runpytest("-ra", str(p1))
result.stdout.fnmatch_lines(
[
"collected 0 items / 1 errors",
"*= ERRORS =*",
"*_ ERROR collecting test_collecterror.py _*",
"E SyntaxError: *",
"*= short test summary info =*",
"ERROR test_collecterror.py",
"*! Interrupted: 1 errors during collection !*",
"*= 1 error in *",
]
)