Fix refleaks in test_with caused by reusing the same exception instance over and over.

This commit is contained in:
Collin Winter 2007-09-01 20:29:04 +00:00
parent c59dacdbd8
commit ba21f618a3
1 changed files with 4 additions and 2 deletions

View File

@ -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():