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

Function test_reference_cycle_namedtuple

tests/test_pretty.py:330–344  ·  tests/test_pretty.py::test_reference_cycle_namedtuple
()

Source from the content-addressed store, hash-verified

328
329
330def test_reference_cycle_namedtuple() -> None:
331 class Example(NamedTuple):
332 x: int
333 y: Any
334
335 test = Example(1, [Example(2, [])])
336 test.y[0].y.append(test)
337 res = pretty_repr(test)
338 assert res == class="st">"Example(x=1, y=[Example(x=2, y=[...])])"
339
340 class="cm"># Not a cyclic reference, just a repeated reference
341 a = Example(2, None)
342 test = Example(1, [a, a])
343 res = pretty_repr(test)
344 assert res == class="st">"Example(x=1, y=[Example(x=2, y=None), Example(x=2, y=None)])"
345
346
347def test_reference_cycle_dataclass() -> None:

Callers

nothing calls this directly

Calls 3

pretty_reprFunction · 0.90
ExampleClass · 0.85
appendMethod · 0.45

Tested by

no test coverage detected