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

Method test_addError

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

Source from the content-addressed store, hash-verified

338 # methods. Contains formatted tracebacks instead
339 # of sys.exc_info() results."
340 def test_addError(self):
341 class Foo(unittest.TestCase):
342 def test_1(self):
343 pass
344
345 test = Foo('test_1')
346 try:
347 raise TypeError()
348 except TypeError:
349 exc_info_tuple = sys.exc_info()
350
351 result = unittest.TestResult()
352
353 result.startTest(test)
354 result.addError(test, exc_info_tuple)
355 result.stopTest(test)
356
357 self.assertFalse(result.wasSuccessful())
358 self.assertEqual(len(result.errors), 1)
359 self.assertEqual(len(result.failures), 0)
360 self.assertEqual(result.testsRun, 1)
361 self.assertEqual(result.shouldStop, False)
362
363 test_case, formatted_exc = result.errors[0]
364 self.assertIs(test_case, test)
365 self.assertIsInstance(formatted_exc, str)
366
367 def test_addError_locals(self):
368 class Foo(unittest.TestCase):

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected