MCPcopy
hub / github.com/Textualize/rich / test_reference_cycle_attrs

Function test_reference_cycle_attrs

tests/test_pretty.py:370–390  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

368
369
370def 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
393def test_reference_cycle_custom_repr() -> None:

Callers

nothing calls this directly

Calls 2

pretty_reprFunction · 0.90
ExampleClass · 0.85

Tested by

no test coverage detected