(self)
| 3625 | self.assertEqual(str(exc_obj), str(exc)) |
| 3626 | |
| 3627 | def test_context(self): |
| 3628 | try: |
| 3629 | try: |
| 3630 | 1/0 |
| 3631 | finally: |
| 3632 | exc = sys.exception() |
| 3633 | exc_context = traceback.TracebackException.from_exception(exc) |
| 3634 | raise Exception("uh oh") |
| 3635 | except Exception as e: |
| 3636 | exc_obj = e |
| 3637 | exc = traceback.TracebackException.from_exception(e) |
| 3638 | expected_stack = traceback.StackSummary.extract( |
| 3639 | traceback.walk_tb(e.__traceback__)) |
| 3640 | self.assertEqual(None, exc.__cause__) |
| 3641 | self.assertEqual(exc_context, exc.__context__) |
| 3642 | self.assertEqual(False, exc.__suppress_context__) |
| 3643 | self.assertEqual(expected_stack, exc.stack) |
| 3644 | with self.assertWarns(DeprecationWarning): |
| 3645 | self.assertEqual(type(exc_obj), exc.exc_type) |
| 3646 | self.assertEqual(type(exc_obj).__name__, exc.exc_type_str) |
| 3647 | self.assertEqual(str(exc_obj), str(exc)) |
| 3648 | |
| 3649 | def test_long_context_chain(self): |
| 3650 | def f(): |
nothing calls this directly
no test coverage detected