()
| 14 | |
| 15 | |
| 16 | def render_tables(): |
| 17 | console = Console( |
| 18 | width=60, |
| 19 | force_terminal=True, |
| 20 | file=io.StringIO(), |
| 21 | legacy_windows=False, |
| 22 | color_system=None, |
| 23 | _environ={}, |
| 24 | ) |
| 25 | |
| 26 | table = Table(title="test table", caption="table caption", expand=False) |
| 27 | table.add_column("foo", footer=Text("total"), no_wrap=True, overflow="ellipsis") |
| 28 | table.add_column("bar", justify="center") |
| 29 | table.add_column("baz", justify="right") |
| 30 | |
| 31 | table.add_row("Averlongwordgoeshere", "banana pancakes", None) |
| 32 | |
| 33 | assert Measurement.get(console, console.options, table) == Measurement(41, 48) |
| 34 | table.expand = True |
| 35 | assert Measurement.get(console, console.options, table) == Measurement(41, 48) |
| 36 | |
| 37 | for width in range(10, 60, 5): |
| 38 | console.print(table, width=width) |
| 39 | |
| 40 | table.expand = False |
| 41 | console.print(table, justify="left") |
| 42 | console.print(table, justify="center") |
| 43 | console.print(table, justify="right") |
| 44 | |
| 45 | assert table.row_count == 1 |
| 46 | |
| 47 | table.row_styles = ["red", "yellow"] |
| 48 | table.add_row("Coffee") |
| 49 | table.add_row("Coffee", "Chocolate", None, "cinnamon") |
| 50 | |
| 51 | assert table.row_count == 3 |
| 52 | |
| 53 | console.print(table) |
| 54 | |
| 55 | table.show_lines = True |
| 56 | console.print(table) |
| 57 | |
| 58 | table.show_footer = True |
| 59 | console.print(table) |
| 60 | |
| 61 | table.show_edge = False |
| 62 | |
| 63 | console.print(table) |
| 64 | |
| 65 | table.padding = 1 |
| 66 | console.print(table) |
| 67 | |
| 68 | table.width = 20 |
| 69 | assert Measurement.get(console, console.options, table) == Measurement(20, 20) |
| 70 | table.expand = False |
| 71 | assert Measurement.get(console, console.options, table) == Measurement(20, 20) |
| 72 | table.expand = True |
| 73 | console.print(table) |
no test coverage detected