Fix tests incorrectly identified if worker crashes during teardown stage
Fix #124
This commit is contained in:
@@ -471,18 +471,34 @@ def test_funcarg_teardown_failure(testdir):
|
||||
assert result.ret
|
||||
|
||||
|
||||
def test_crashing_item(testdir):
|
||||
@pytest.mark.parametrize('when', ['setup', 'call', 'teardown'])
|
||||
def test_crashing_item(testdir, when):
|
||||
"""Ensure crashing item is correctly reported during all testing stages"""
|
||||
code = dict(setup='', call='', teardown='')
|
||||
code[when] = 'py.process.kill(os.getpid())'
|
||||
p = testdir.makepyfile("""
|
||||
import py
|
||||
import os
|
||||
def test_crash():
|
||||
py.process.kill(os.getpid())
|
||||
def test_noncrash():
|
||||
import py
|
||||
import pytest
|
||||
|
||||
@pytest.fixture
|
||||
def fix():
|
||||
{setup}
|
||||
yield
|
||||
{teardown}
|
||||
|
||||
def test_crash(fix):
|
||||
{call}
|
||||
pass
|
||||
""")
|
||||
|
||||
def test_ok():
|
||||
pass
|
||||
""".format(**code))
|
||||
passes = 2 if when == 'teardown' else 1
|
||||
result = testdir.runpytest("-n2", p)
|
||||
result.stdout.fnmatch_lines([
|
||||
"*crashed*test_crash*", "*1 failed*1 passed*"
|
||||
"*crashed*test_crash*",
|
||||
"*1 failed*%d passed*" % passes,
|
||||
])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user