Skip to content

Commit

Permalink
pytester: quick fix error introduced in pytest-dev#5990 (pytest-dev#6353
Browse files Browse the repository at this point in the history
)

pytester: quick fix error introduced in pytest-dev#5990
  • Loading branch information
nicoddemus authored Dec 27, 2019
2 parents afa899d + dc7bf51 commit 8077168
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
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)

0 comments on commit 8077168

Please sign in to comment.