MCPcopy
hub / github.com/Textualize/textual / test_content_box

Function test_content_box

tests/test_box_model.py:10–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9
10async def test_content_box():
11 one = Fraction(1)
12
13 class TestWidget(Widget):
14 def get_content_width(self, container: Size, parent: Size) -> int:
15 assert False, "must not be called"
16
17 def get_content_height(self, container: Size, parent: Size) -> int:
18 assert False, "must not be called"
19
20 widget = TestWidget()
21
22 # border-box is default
23 assert widget.styles.box_sizing == "border-box"
24
25 widget.styles.width = 10
26 widget.styles.height = 8
27 widget.styles.padding = 1
28 widget.styles.border = ("solid", "red")
29
30 box_model = widget._get_box_model(
31 Size(60, 20),
32 Size(80, 24),
33 one,
34 one,
35 )
36 # Size should be inclusive of padding / border
37 assert box_model == BoxModel(Fraction(10), Fraction(8), Spacing(0, 0, 0, 0))
38
39 # Switch to content-box
40 widget.styles.box_sizing = "content-box"
41
42 box_model = widget._get_box_model(Size(60, 20), Size(80, 24), one, one)
43 # width and height have added padding / border to accommodate content
44 assert box_model == BoxModel(Fraction(14), Fraction(12), Spacing(0, 0, 0, 0))
45
46
47async def test_width():

Callers

nothing calls this directly

Calls 5

SizeClass · 0.90
BoxModelClass · 0.90
SpacingClass · 0.90
_get_box_modelMethod · 0.80
TestWidgetClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…