(self)
| 138 | self.assertIn(f'{CustomErrorRepr}: bar', msg2) |
| 139 | |
| 140 | def testCleanupInRun(self): |
| 141 | blowUp = False |
| 142 | ordering = [] |
| 143 | |
| 144 | class TestableTest(unittest.TestCase): |
| 145 | def setUp(self): |
| 146 | ordering.append('setUp') |
| 147 | test.addCleanup(cleanup2) |
| 148 | if blowUp: |
| 149 | raise CustomError('foo') |
| 150 | |
| 151 | def testNothing(self): |
| 152 | ordering.append('test') |
| 153 | test.addCleanup(cleanup3) |
| 154 | |
| 155 | def tearDown(self): |
| 156 | ordering.append('tearDown') |
| 157 | |
| 158 | test = TestableTest('testNothing') |
| 159 | |
| 160 | def cleanup1(): |
| 161 | ordering.append('cleanup1') |
| 162 | def cleanup2(): |
| 163 | ordering.append('cleanup2') |
| 164 | def cleanup3(): |
| 165 | ordering.append('cleanup3') |
| 166 | test.addCleanup(cleanup1) |
| 167 | |
| 168 | def success(some_test): |
| 169 | self.assertEqual(some_test, test) |
| 170 | ordering.append('success') |
| 171 | |
| 172 | result = unittest.TestResult() |
| 173 | result.addSuccess = success |
| 174 | |
| 175 | test.run(result) |
| 176 | self.assertEqual(ordering, ['setUp', 'test', 'tearDown', 'cleanup3', |
| 177 | 'cleanup2', 'cleanup1', 'success']) |
| 178 | |
| 179 | blowUp = True |
| 180 | ordering = [] |
| 181 | test = TestableTest('testNothing') |
| 182 | test.addCleanup(cleanup1) |
| 183 | test.run(result) |
| 184 | self.assertEqual(ordering, ['setUp', 'cleanup2', 'cleanup1']) |
| 185 | |
| 186 | def testTestCaseDebugExecutesCleanups(self): |
| 187 | ordering = [] |
nothing calls this directly
no test coverage detected