Fix tests incorrectly identified if worker crashes during teardown stage

Fix #124
This commit is contained in:
Bruno Oliveira
2017-08-10 10:43:40 -03:00
parent 79f1b6dab2
commit f8e138b986
5 changed files with 46 additions and 19 deletions

View File

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