(self)
| 3694 | self.assertEqual(str(exc_obj), str(exc)) |
| 3695 | |
| 3696 | def test_compact_no_cause(self): |
| 3697 | try: |
| 3698 | try: |
| 3699 | 1/0 |
| 3700 | finally: |
| 3701 | exc = sys.exception() |
| 3702 | exc_context = traceback.TracebackException.from_exception(exc) |
| 3703 | raise Exception("uh oh") |
| 3704 | except Exception as e: |
| 3705 | exc_obj = e |
| 3706 | exc = traceback.TracebackException.from_exception(e, compact=True) |
| 3707 | expected_stack = traceback.StackSummary.extract( |
| 3708 | traceback.walk_tb(exc_obj.__traceback__)) |
| 3709 | self.assertEqual(None, exc.__cause__) |
| 3710 | self.assertEqual(exc_context, exc.__context__) |
| 3711 | self.assertEqual(False, exc.__suppress_context__) |
| 3712 | self.assertEqual(expected_stack, exc.stack) |
| 3713 | with self.assertWarns(DeprecationWarning): |
| 3714 | self.assertEqual(type(exc_obj), exc.exc_type) |
| 3715 | self.assertEqual(type(exc_obj).__name__, exc.exc_type_str) |
| 3716 | self.assertEqual(str(exc_obj), str(exc)) |
| 3717 | |
| 3718 | def test_no_save_exc_type(self): |
| 3719 | try: |
nothing calls this directly
no test coverage detected