MCPcopy Index your code
hub / github.com/Textualize/textual / test_render_border_label

Function test_render_border_label

tests/test_border.py:209–271  ·  view source on GitHub ↗

Test label rendering with styling, with and without overflow.

()

Source from the content-addressed store, hash-verified

207
208
209def test_render_border_label():
210 """Test label rendering with styling, with and without overflow."""
211
212 label = "[b][on red]What [i]is up[/on red] with you?[/]"
213 border_style = Style.parse("green on blue")
214
215 # Implicit test on the number of segments returned:
216 segments = list(
217 render_border_label(
218 (Content.from_markup(label), Style.null()),
219 True,
220 "round",
221 9999,
222 Style(),
223 Style(),
224 border_style,
225 True,
226 True,
227 )
228 )
229
230 for segment in segments:
231 print("!!", segment)
232
233 blank1, what, is_up, with_you, blank2 = segments
234
235 expected_blank = Segment(" ", border_style.rich_style)
236 assert blank1 == expected_blank
237 assert blank2 == expected_blank
238
239 what_style = Style.parse("b on red")
240 expected_what = Segment("What ", (border_style + what_style).rich_style)
241 print(what)
242 print(expected_what)
243 assert what == expected_what
244
245 is_up_style = Style.parse("b on red i")
246 expected_is_up = Segment("is up", (border_style + is_up_style).rich_style)
247 assert is_up == expected_is_up
248
249 with_you_style = Style.parse("b i")
250 expected_with_you = Segment(
251 " with you?", (border_style + with_you_style).rich_style
252 )
253 assert with_you == expected_with_you
254
255 blank1, what, blank2 = render_border_label(
256 (Content.from_markup(label), Style()),
257 True,
258 "round",
259 5 + 4, # 5 where "What…" fits + 2 for the blank spaces + 2 for the corners.
260 Style(),
261 Style(),
262 border_style,
263 True, # This corner costs 2 cells.
264 True, # This corner costs 2 cells.
265 )
266

Callers

nothing calls this directly

Calls 5

render_border_labelFunction · 0.90
StyleClass · 0.90
from_markupMethod · 0.80
parseMethod · 0.45
nullMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…