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

Function test_placement_table_box_elements

tests/test_table.py:307–363  ·  view source on GitHub ↗

Ensure box drawing characters correctly positioned.

(show_header, show_footer, expected)

Source from the content-addressed store, hash-verified

305 ],
306)
307def test_placement_table_box_elements(show_header, show_footer, expected):
308 """Ensure box drawing characters correctly positioned."""
309
310 table = Table(
311 box=box.ASCII, show_header=show_header, show_footer=show_footer, padding=0
312 )
313
314 # content rows indicated by numerals, pure dividers by letters
315 table.box.__dict__.update(
316 top_left="a",
317 top="b",
318 top_divider="c",
319 top_right="d",
320 head_left="1",
321 head_vertical="2",
322 head_right="3",
323 head_row_left="e",
324 head_row_horizontal="f",
325 head_row_cross="g",
326 head_row_right="h",
327 mid_left="4",
328 mid_vertical="5",
329 mid_right="6",
330 row_left="i",
331 row_horizontal="j",
332 row_cross="k",
333 row_right="l",
334 foot_left="7",
335 foot_vertical="8",
336 foot_right="9",
337 foot_row_left="m",
338 foot_row_horizontal="n",
339 foot_row_cross="o",
340 foot_row_right="p",
341 bottom_left="q",
342 bottom="r",
343 bottom_divider="s",
344 bottom_right="t",
345 )
346
347 # add content - note headers title case, footers upper case
348 table.add_column("Month", "MONTH", width=5)
349 table.add_column("Nickname", "NICKNAME", width=9)
350 table.add_column("Cost", "COST", width=4)
351 table.add_column("Gross", "GROSS", width=5)
352
353 table.add_row("Dec", "Skywalker", "275M", "375M")
354 table.add_row("May", "Solo", "275M", "393M")
355 table.add_section()
356 table.add_row("Dec", "Last Jedi", "262M", "1333M")
357
358 console = Console(record=True, width=28)
359 console.print(table)
360 output = console.export_text()
361 print(repr(output))
362
363 assert output == expected
364

Callers

nothing calls this directly

Calls 9

add_columnMethod · 0.95
add_rowMethod · 0.95
add_sectionMethod · 0.95
printMethod · 0.95
export_textMethod · 0.95
TableClass · 0.90
ConsoleClass · 0.90
printFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected