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

pytester: quick fix error introduced in #5990 #6353

Merged
merged 1 commit into from
Dec 27, 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/6532.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix problem with ``testdir`` not recognizing errors correctly in runs with a single test.
2 changes: 1 addition & 1 deletion src/_pytest/pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def assert_outcomes(
"passed": d.get("passed", 0),
"skipped": d.get("skipped", 0),
"failed": d.get("failed", 0),
"error": d.get("error", 0),
"error": d.get("error", 0) + d.get("errors", 0),
"xpassed": d.get("xpassed", 0),
"xfailed": d.get("xfailed", 0),
}
Expand Down
20 changes: 20 additions & 0 deletions testing/test_pytester.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,3 +682,23 @@ def test_run_result_repr():
repr(r) == "<RunResult ret=99 len(stdout.lines)=3"
" len(stderr.lines)=4 duration=0.50s>"
)


def test_run_pytester_with_single_test(testdir):
testcode = """
import pytest

@pytest.fixture
def bad_fixture():
raise Exception("bad")

def test_error1(bad_fixture):
pass

def test_error2(bad_fixture):
pass
"""

testdir.makepyfile(testcode)
result = testdir.runpytest()
result.assert_outcomes(error=2)