diff --git a/CHANGELOG b/CHANGELOG index cd46a64ea..0db181d24 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/_pytest/unittest.py b/_pytest/unittest.py index f283d0348..571a8360c 100644 --- a/_pytest/unittest.py +++ b/_pytest/unittest.py @@ -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__): diff --git a/testing/test_unittest.py b/testing/test_unittest.py index 3752cf868..98a8ce02b 100644 --- a/testing/test_unittest.py +++ b/testing/test_unittest.py @@ -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) + +