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

Function test_pretty_dataclass

tests/test_pretty.py:174–191  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

172
173
174def test_pretty_dataclass() -> None:
175 dc = ExampleDataclass(1000, "Hello, World", 999, ["foo", "bar", "baz"])
176 result = pretty_repr(dc, max_width=80)
177 print(repr(result))
178 assert (
179 result
180 == "ExampleDataclass(foo=1000, bar='Hello, World', baz=['foo', 'bar', 'baz'])"
181 )
182 result = pretty_repr(dc, max_width=16)
183 print(repr(result))
184 assert (
185 result
186 == "ExampleDataclass(\n foo=1000,\n bar='Hello, World',\n baz=[\n 'foo',\n 'bar',\n 'baz'\n ]\n)"
187 )
188 dc.bar = dc
189 result = pretty_repr(dc, max_width=80)
190 print(repr(result))
191 assert result == "ExampleDataclass(foo=1000, bar=..., baz=['foo', 'bar', 'baz'])"
192
193
194def test_empty_dataclass() -> None:

Callers

nothing calls this directly

Calls 3

pretty_reprFunction · 0.90
ExampleDataclassClass · 0.85
printFunction · 0.50

Tested by

no test coverage detected