fix issue333: fix a case of bad unittest/pytest hook interaction.

This commit is contained in:
holger krekel 2013-09-09 09:56:53 +02:00
parent 88dc5f8204
commit d565df90ad
3 changed files with 24 additions and 1 deletions

View File

@ -4,6 +4,8 @@ Changes between 2.3.5 and 2.4.DEV
- make "import pdb ; pdb.set_trace()" work natively wrt capturing (no "-s" needed
anymore), making ``pytest.set_trace()`` a mere shortcut.
- fix issue333: fix a case of bad unittest/pytest hook interaction.
- fix issue181: --pdb now also works on collect errors (and
on internal errors) . This was implemented by a slight internal
refactoring and the introduction of a new hook

View File

@ -150,7 +150,10 @@ def pytest_runtest_makereport(item, call):
if isinstance(item, TestCaseFunction):
if item._excinfo:
call.excinfo = item._excinfo.pop(0)
del call.result
try:
del call.result
except AttributeError:
pass
# twisted trial support
def pytest_runtest_protocol(item, __multicall__):

View File

@ -654,3 +654,21 @@ def test_no_teardown_if_setupclass_failed(testdir):
reprec = testdir.inline_run(testpath)
reprec.assertoutcome(passed=1, failed=1)
def test_issue333_result_clearing(testdir):
testdir.makeconftest("""
def pytest_runtest_call(__multicall__, item):
__multicall__.execute()
assert 0
""")
testdir.makepyfile("""
import unittest
class TestIt(unittest.TestCase):
def test_func(self):
0/0
""")
reprec = testdir.inline_run()
reprec.assertoutcome(failed=1)