From: Collin Winter Date: Sat, 1 Sep 2007 20:29:04 +0000 (+0000) Subject: Fix refleaks in test_with caused by reusing the same exception instance over and... X-Git-Tag: v3.0a2~478 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ba21f618a301a36b13a25c2d51e74562363c6d67;p=thirdparty%2FPython%2Fcpython.git Fix refleaks in test_with caused by reusing the same exception instance over and over. --- diff --git a/Lib/test/test_with.py b/Lib/test/test_with.py index 4fc8fe9fca51..a7bc2068b4c8 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():