(self)
| 109 | |
| 110 | @support.force_not_colorized |
| 111 | def testCleanUpWithErrors(self): |
| 112 | class TestableTest(unittest.TestCase): |
| 113 | def testNothing(self): |
| 114 | pass |
| 115 | |
| 116 | test = TestableTest('testNothing') |
| 117 | result = unittest.TestResult() |
| 118 | outcome = test._outcome = _Outcome(result=result) |
| 119 | |
| 120 | CleanUpExc = CustomError('foo') |
| 121 | exc2 = CustomError('bar') |
| 122 | def cleanup1(): |
| 123 | raise CleanUpExc |
| 124 | |
| 125 | def cleanup2(): |
| 126 | raise exc2 |
| 127 | |
| 128 | test.addCleanup(cleanup1) |
| 129 | test.addCleanup(cleanup2) |
| 130 | |
| 131 | self.assertFalse(test.doCleanups()) |
| 132 | self.assertFalse(outcome.success) |
| 133 | |
| 134 | (_, msg2), (_, msg1) = result.errors |
| 135 | self.assertIn('in cleanup1', msg1) |
| 136 | self.assertIn('raise CleanUpExc', msg1) |
| 137 | self.assertIn(f'{CustomErrorRepr}: foo', msg1) |
| 138 | self.assertIn('in cleanup2', msg2) |
| 139 | self.assertIn('raise exc2', msg2) |
| 140 | self.assertIn(f'{CustomErrorRepr}: bar', msg2) |
| 141 | |
| 142 | def testCleanupInRun(self): |
| 143 | blowUp = False |
nothing calls this directly
no test coverage detected