(self)
| 3647 | self.assertEqual(str(exc_obj), str(exc)) |
| 3648 | |
| 3649 | def test_long_context_chain(self): |
| 3650 | def f(): |
| 3651 | try: |
| 3652 | 1/0 |
| 3653 | except ZeroDivisionError: |
| 3654 | f() |
| 3655 | |
| 3656 | try: |
| 3657 | f() |
| 3658 | except RecursionError as e: |
| 3659 | exc_obj = e |
| 3660 | else: |
| 3661 | self.fail("Exception not raised") |
| 3662 | |
| 3663 | te = traceback.TracebackException.from_exception(exc_obj) |
| 3664 | res = list(te.format()) |
| 3665 | |
| 3666 | # many ZeroDiv errors followed by the RecursionError |
| 3667 | self.assertGreater(len(res), sys.getrecursionlimit()) |
| 3668 | self.assertGreater( |
| 3669 | len([l for l in res if 'ZeroDivisionError:' in l]), |
| 3670 | sys.getrecursionlimit() * 0.5) |
| 3671 | self.assertIn( |
| 3672 | "RecursionError: maximum recursion depth exceeded", res[-1]) |
| 3673 | |
| 3674 | def test_compact_with_cause(self): |
| 3675 | try: |
nothing calls this directly
no test coverage detected