| 8 | |
| 9 | |
| 10 | def test_rule(): |
| 11 | console = Console( |
| 12 | width=16, |
| 13 | file=io.StringIO(), |
| 14 | force_terminal=True, |
| 15 | legacy_windows=False, |
| 16 | _environ={}, |
| 17 | ) |
| 18 | console.print(Rule()) |
| 19 | console.print(Rule("foo")) |
| 20 | console.rule(Text("foo", style="bold")) |
| 21 | console.rule("foobarbazeggfoobarbazegg") |
| 22 | expected = "\x1b[92m────────────────\x1b[0m\n" |
| 23 | expected += "\x1b[92m───── \x1b[0mfoo\x1b[92m ──────\x1b[0m\n" |
| 24 | expected += "\x1b[92m───── \x1b[0m\x1b[1mfoo\x1b[0m\x1b[92m ──────\x1b[0m\n" |
| 25 | expected += "\x1b[92m─ \x1b[0mfoobarbazeg…\x1b[92m ─\x1b[0m\n" |
| 26 | |
| 27 | result = console.file.getvalue() |
| 28 | assert result == expected |
| 29 | |
| 30 | |
| 31 | def test_rule_error(): |