()
| 7 | |
| 8 | |
| 9 | def test_decode(): |
| 10 | console = Console( |
| 11 | force_terminal=True, legacy_windows=False, color_system="truecolor" |
| 12 | ) |
| 13 | console.begin_capture() |
| 14 | console.print("Hello") |
| 15 | console.print("[b]foo[/b]") |
| 16 | console.print("[link http://example.org]bar") |
| 17 | console.print("[#ff0000 on color(200)]red") |
| 18 | console.print("[color(200) on #ff0000]red") |
| 19 | terminal_codes = console.end_capture() |
| 20 | |
| 21 | decoder = AnsiDecoder() |
| 22 | lines = list(decoder.decode(terminal_codes)) |
| 23 | print(repr(lines)) |
| 24 | expected = [ |
| 25 | Text("Hello"), |
| 26 | Text("foo", spans=[Span(0, 3, Style.parse("bold"))]), |
| 27 | Text("bar", spans=[Span(0, 3, Style.parse("link http://example.org"))]), |
| 28 | Text("red", spans=[Span(0, 3, Style.parse("#ff0000 on color(200)"))]), |
| 29 | Text("red", spans=[Span(0, 3, Style.parse("color(200) on #ff0000"))]), |
| 30 | Text(""), |
| 31 | ] |
| 32 | |
| 33 | assert lines == expected |
| 34 | |
| 35 | |
| 36 | def test_decode_example(): |
nothing calls this directly
no test coverage detected