[Pytest-commit] commit/pytest: hpk42: fix issue333: fix a case of bad unittest/pytest hook interaction.

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Mon Sep 9 09:57:54 CEST 2013


1 new commit in pytest:

https://bitbucket.org/hpk42/pytest/commits/a2b5a4f7d445/
Changeset:   a2b5a4f7d445
User:        hpk42
Date:        2013-09-09 09:56:53
Summary:     fix issue333: fix a case of bad unittest/pytest hook interaction.
Affected #:  3 files

diff -r 90e7a7a4c03e0339d6228fd40403ea7824e250f1 -r a2b5a4f7d4451f5aa1d270ec928520ee081ed003 CHANGELOG
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,8 @@
 - 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 -r 90e7a7a4c03e0339d6228fd40403ea7824e250f1 -r a2b5a4f7d4451f5aa1d270ec928520ee081ed003 _pytest/unittest.py
--- a/_pytest/unittest.py
+++ b/_pytest/unittest.py
@@ -150,7 +150,10 @@
     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 -r 90e7a7a4c03e0339d6228fd40403ea7824e250f1 -r a2b5a4f7d4451f5aa1d270ec928520ee081ed003 testing/test_unittest.py
--- a/testing/test_unittest.py
+++ b/testing/test_unittest.py
@@ -654,3 +654,21 @@
     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)
+
+

Repository URL: https://bitbucket.org/hpk42/pytest/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.


More information about the pytest-commit mailing list