summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCollin Winter <collinw@gmail.com>2007-09-01 20:29:04 (GMT)
committerCollin Winter <collinw@gmail.com>2007-09-01 20:29:04 (GMT)
commitba21f618a301a36b13a25c2d51e74562363c6d67 (patch)
treec919343ebe45c7316a09880e0e877961f4de3f4d
parentc59dacdbd84df0c4f121caa48e07933512177cd2 (diff)
downloadcpython-ba21f618a301a36b13a25c2d51e74562363c6d67.zip
cpython-ba21f618a301a36b13a25c2d51e74562363c6d67.tar.gz
cpython-ba21f618a301a36b13a25c2d51e74562363c6d67.tar.bz2
Fix refleaks in test_with caused by reusing the same exception instance over and over.
-rw-r--r--Lib/test/test_with.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py
index 4fc8fe9..a7bc206 100644
--- a/Lib/test/test_with.py
+++ b/Lib/test/test_with.py
@@ -187,7 +187,9 @@ class FailureTestCase(unittest.TestCase):
self.assertRaises(RuntimeError, shouldThrow)
class ContextmanagerAssertionMixin(object):
- TEST_EXCEPTION = RuntimeError("test exception")
+
+ def setUp(self):
+ self.TEST_EXCEPTION = RuntimeError("test exception")
def assertInWithManagerInvariants(self, mock_manager):
self.assertTrue(mock_manager.enter_called)
@@ -353,7 +355,7 @@ class NestedNonexceptionalTestCase(unittest.TestCase,
self.assertAfterWithManagerInvariantsNoError(mock_nested)
-class ExceptionalTestCase(unittest.TestCase, ContextmanagerAssertionMixin):
+class ExceptionalTestCase(ContextmanagerAssertionMixin, unittest.TestCase):
def testSingleResource(self):
cm = mock_contextmanager_generator()
def shouldThrow():