pytester: quick fix error introduced in #5990

- added a test to check this condition

Signed-off-by: Alexandre Mulatinho <alex@mulatinho.net>
This commit is contained in:
Alexandre Mulatinho 2019-12-18 15:15:53 -03:00
parent 1c0ab3c2a3
commit dc7bf518b3
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1 @@
Fix problem with ``testdir`` not recognizing errors correctly in runs with a single test.

View File

@ -456,7 +456,7 @@ class RunResult:
"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),
}

View File

@ -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)