(self)
| 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): |
nothing calls this directly
no test coverage detected