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

Function test_render

tests/test_layout.py:35–67  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33
34@pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
35def test_render():
36 layout = Layout(name="root")
37 repr(layout)
38
39 layout.split_column(Layout(name="top"), Layout(name="bottom"))
40 top = layout["top"]
41 top.update(Panel("foo"))
42
43 print(type(top._renderable))
44 assert isinstance(top.renderable, Panel)
45 layout["bottom"].split_row(Layout(name="left"), Layout(name="right"))
46
47 assert layout["root"].name == "root"
48 assert layout["left"].name == "left"
49
50 assert isinstance(layout.map, dict)
51
52 with pytest.raises(KeyError):
53 top["asdasd"]
54
55 layout["left"].update("foobar")
56 print(layout["left"].children)
57
58 console = Console(width=60, color_system=None)
59
60 with console.capture() as capture:
61 console.print(layout, height=10)
62
63 result = capture.get()
64 print(repr(result))
65 expected = "╭──────────────────────────────────────────────────────────╮\n│ foo │\n│ │\n│ │\n╰──────────────────────────────────────────────────────────╯\nfoobar ╭───── 'right' (30 x 5) ─────╮\n │ │\n │ Layout(name='right') │\n │ │\n ╰────────────────────────────╯\n"
66
67 assert result == expected
68
69
70def test_tree():

Callers

nothing calls this directly

Calls 10

split_columnMethod · 0.95
captureMethod · 0.95
printMethod · 0.95
LayoutClass · 0.90
PanelClass · 0.90
ConsoleClass · 0.90
split_rowMethod · 0.80
printFunction · 0.50
updateMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected