Regression test for https://github.com/Textualize/rich/issues/3708 Test this doesn't create an infinite loop.
()
| 376 | |
| 377 | |
| 378 | def test_recursive_exception() -> None: |
| 379 | """Regression test for https://github.com/Textualize/rich/issues/3708 |
| 380 | |
| 381 | Test this doesn't create an infinite loop. |
| 382 | |
| 383 | """ |
| 384 | console = Console() |
| 385 | |
| 386 | def foo() -> None: |
| 387 | try: |
| 388 | raise RuntimeError("Hello") |
| 389 | except Exception as e: |
| 390 | raise e from e |
| 391 | |
| 392 | def bar() -> None: |
| 393 | try: |
| 394 | foo() |
| 395 | except Exception as e: |
| 396 | assert e is e.__cause__ |
| 397 | console.print_exception(show_locals=True) |
| 398 | |
| 399 | bar() |