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

Method test_addFailure

Lib/test/test_unittest/test_result.py:181–206  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

179 # methods. Contains formatted tracebacks instead
180 # of sys.exc_info() results."
181 def test_addFailure(self):
182 class Foo(unittest.TestCase):
183 def test_1(self):
184 pass
185
186 test = Foo('test_1')
187 try:
188 test.fail("foo")
189 except AssertionError:
190 exc_info_tuple = sys.exc_info()
191
192 result = unittest.TestResult()
193
194 result.startTest(test)
195 result.addFailure(test, exc_info_tuple)
196 result.stopTest(test)
197
198 self.assertFalse(result.wasSuccessful())
199 self.assertEqual(len(result.errors), 0)
200 self.assertEqual(len(result.failures), 1)
201 self.assertEqual(result.testsRun, 1)
202 self.assertEqual(result.shouldStop, False)
203
204 test_case, formatted_exc = result.failures[0]
205 self.assertIs(test_case, test)
206 self.assertIsInstance(formatted_exc, str)
207
208 def test_addFailure_filter_traceback_frames(self):
209 class Foo(unittest.TestCase):

Callers

nothing calls this directly

Calls 10

startTestMethod · 0.95
addFailureMethod · 0.95
stopTestMethod · 0.95
wasSuccessfulMethod · 0.95
assertFalseMethod · 0.80
assertIsInstanceMethod · 0.80
FooClass · 0.70
failMethod · 0.45
assertEqualMethod · 0.45
assertIsMethod · 0.45

Tested by

no test coverage detected