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

Function test_pretty

tests/test_pretty.py:144–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

142
143
144def test_pretty() -> None:
145 test = {
146 "foo": [1, 2, 3, (4, 5, {6}, 7, 8, {9}), {}],
147 "bar": {"egg": "baz", "words": ["Hello World"] * 10},
148 False: "foo",
149 True: "",
150 "text": ("Hello World", "foo bar baz egg"),
151 }
152
153 result = pretty_repr(test, max_width=80)
154 print(result)
155 expected = "{\n 'foo': [1, 2, 3, (4, 5, {6}, 7, 8, {9}), {}],\n 'bar': {\n 'egg': 'baz',\n 'words': [\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World',\n 'Hello World'\n ]\n },\n False: 'foo',\n True: '',\n 'text': ('Hello World', 'foo bar baz egg')\n}"
156 print(expected)
157 assert result == expected
158
159
160@dataclass

Callers

nothing calls this directly

Calls 2

pretty_reprFunction · 0.90
printFunction · 0.50

Tested by

no test coverage detected