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