pytester: quick fix error introduced in #5990 (#6353)

pytester: quick fix error introduced in #5990
This commit is contained in:
Bruno Oliveira 2019-12-27 13:28:11 -03:00 committed by GitHub
commit 8077168387
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)