()
| 65 | |
| 66 | |
| 67 | def test_cast_recursive(): |
| 68 | class B: |
| 69 | def __rich__(self) -> "A": |
| 70 | return A() |
| 71 | |
| 72 | def __repr__(self) -> str: |
| 73 | return "<B>" |
| 74 | |
| 75 | class A: |
| 76 | def __rich__(self) -> B: |
| 77 | return B() |
| 78 | |
| 79 | def __repr__(self) -> str: |
| 80 | return "<A>" |
| 81 | |
| 82 | console = Console(file=io.StringIO()) |
| 83 | console.print(A()) |
| 84 | assert console.file.getvalue() == "<B>\n" |