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

Function test__get_default_css

tests/test_dom.py:115–154  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114
115def test__get_default_css():
116 class A(DOMNode):
117 pass
118
119 class B(A):
120 pass
121
122 class C(B):
123 DEFAULT_CSS = "C"
124
125 class D(C):
126 pass
127
128 class E(D):
129 DEFAULT_CSS = "E"
130
131 node = DOMNode()
132 node_css = node._get_default_css()
133 a = A()
134 a_css = a._get_default_css()
135 b = B()
136 b_css = b._get_default_css()
137 c = C()
138 c_css = c._get_default_css()
139 d = D()
140 d_css = d._get_default_css()
141 e = E()
142 e_css = e._get_default_css()
143
144 # Descendants that don't assign to DEFAULT_CSS don't add new CSS to the stack.
145 assert len(node_css) == len(a_css) == len(b_css) == 0
146 assert len(c_css) == len(d_css) == 1
147 assert len(e_css) == 2
148
149 # Descendants do push the priority of the ancestors' rules down.
150 assert c_css[0][2] == d_css[0][2] + 1 == 0
151
152 # The CSS on the stack is the correct one.
153 assert e_css[0][1:] == ("E", 0, "E")
154 assert e_css[1][1:] == ("C", -2, "C")
155
156
157def test_component_classes_inheritance():

Callers

nothing calls this directly

Calls 7

_get_default_cssMethod · 0.95
DOMNodeClass · 0.90
AClass · 0.85
BClass · 0.85
CClass · 0.85
DClass · 0.85
EClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…