()
| 368 | |
| 369 | |
| 370 | def test_reference_cycle_attrs() -> None: |
| 371 | @attr.define |
| 372 | class Example: |
| 373 | x: int |
| 374 | y: Any |
| 375 | |
| 376 | test = Example(1, None) |
| 377 | test.y = test |
| 378 | res = pretty_repr(test) |
| 379 | assert res == "Example(x=1, y=...)" |
| 380 | |
| 381 | test = Example(1, Example(2, None)) |
| 382 | test.y.y = test |
| 383 | res = pretty_repr(test) |
| 384 | assert res == "Example(x=1, y=Example(x=2, y=...))" |
| 385 | |
| 386 | # Not a cyclic reference, just a repeated reference |
| 387 | a = Example(2, None) |
| 388 | test = Example(1, [a, a]) |
| 389 | res = pretty_repr(test) |
| 390 | assert res == "Example(x=1, y=[Example(x=2, y=None), Example(x=2, y=None)])" |
| 391 | |
| 392 | |
| 393 | def test_reference_cycle_custom_repr() -> None: |
nothing calls this directly
no test coverage detected