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:
parent
1c0ab3c2a3
commit
dc7bf518b3
|
@ -0,0 +1 @@
|
||||||
|
Fix problem with ``testdir`` not recognizing errors correctly in runs with a single test.
|
|
@ -456,7 +456,7 @@ class RunResult:
|
||||||
"passed": d.get("passed", 0),
|
"passed": d.get("passed", 0),
|
||||||
"skipped": d.get("skipped", 0),
|
"skipped": d.get("skipped", 0),
|
||||||
"failed": d.get("failed", 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),
|
"xpassed": d.get("xpassed", 0),
|
||||||
"xfailed": d.get("xfailed", 0),
|
"xfailed": d.get("xfailed", 0),
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,3 +682,23 @@ def test_run_result_repr():
|
||||||
repr(r) == "<RunResult ret=99 len(stdout.lines)=3"
|
repr(r) == "<RunResult ret=99 len(stdout.lines)=3"
|
||||||
" len(stderr.lines)=4 duration=0.50s>"
|
" 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)
|
||||||
|
|
Loading…
Reference in New Issue