MCPcopy Index your code
hub / github.com/python/cpython / testCleanUpWithErrors

Method testCleanUpWithErrors

Lib/test/test_unittest/test_runner.py:111–140  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

_OutcomeClass · 0.90
addCleanupMethod · 0.80
assertFalseMethod · 0.80
doCleanupsMethod · 0.80
assertInMethod · 0.80
TestableTestClass · 0.70
CustomErrorClass · 0.70

Tested by

no test coverage detected