diff options
author | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-12-19 03:19:47 (GMT) |
---|---|---|
committer | Michael Foord <fuzzyman@voidspace.org.uk> | 2010-12-19 03:19:47 (GMT) |
commit | b3468f79efa45c8adaf86c0b9b797b9b3d4c12a2 (patch) | |
tree | 14e9ae4dcb071ee7bf154026ecac93c3ea352c7a /Lib/unittest/test/test_runner.py | |
parent | addc6f5a21d5d04c5bf895e8ea46f67de129d75c (diff) | |
download | cpython-b3468f79efa45c8adaf86c0b9b797b9b3d4c12a2.zip cpython-b3468f79efa45c8adaf86c0b9b797b9b3d4c12a2.tar.gz cpython-b3468f79efa45c8adaf86c0b9b797b9b3d4c12a2.tar.bz2 |
Issue 10611. Issue 9857. Improve the way exception handling, including test skipping, is done inside TestCase.run
Diffstat (limited to 'Lib/unittest/test/test_runner.py')
-rw-r--r-- | Lib/unittest/test/test_runner.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/Lib/unittest/test/test_runner.py b/Lib/unittest/test/test_runner.py index 8f4aaaa..8f98a02 100644 --- a/Lib/unittest/test/test_runner.py +++ b/Lib/unittest/test/test_runner.py @@ -34,9 +34,7 @@ class TestCleanUp(unittest.TestCase): [(cleanup1, (1, 2, 3), dict(four='hello', five='goodbye')), (cleanup2, (), {})]) - result = test.doCleanups() - self.assertTrue(result) - + self.assertTrue(test.doCleanups()) self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))]) def testCleanUpWithErrors(self): @@ -44,14 +42,12 @@ class TestCleanUp(unittest.TestCase): def testNothing(self): pass - class MockResult(object): + class MockOutcome(object): + success = True errors = [] - def addError(self, test, exc_info): - self.errors.append((test, exc_info)) - result = MockResult() test = TestableTest('testNothing') - test._resultForDoCleanups = result + test._outcomeForDoCleanups = MockOutcome exc1 = Exception('foo') exc2 = Exception('bar') @@ -65,10 +61,11 @@ class TestCleanUp(unittest.TestCase): test.addCleanup(cleanup2) self.assertFalse(test.doCleanups()) + self.assertFalse(MockOutcome.success) - (test1, (Type1, instance1, _)), (test2, (Type2, instance2, _)) = reversed(MockResult.errors) - self.assertEqual((test1, Type1, instance1), (test, Exception, exc1)) - self.assertEqual((test2, Type2, instance2), (test, Exception, exc2)) + (Type1, instance1, _), (Type2, instance2, _) = reversed(MockOutcome.errors) + self.assertEqual((Type1, instance1), (Exception, exc1)) + self.assertEqual((Type2, instance2), (Exception, exc2)) def testCleanupInRun(self): blowUp = False |