def test_rich_console_ex_ansi() -> None: """Validate that ANSI sent to sys.stdout does not become garbage in record.""" print() console = Console(force_terminal=True, record=True, redirect=True) console.print("[green]this from Console.print()[/green]", style="red") text = console.export_text(clear=False) assert "this from Console" in text html = console.export_html(clear=False) assert "#008000" in html
def test_console_print_ansi() -> None: """Validates that Console.print() with ANSI does not make break them.""" console = Console(force_terminal=True, record=True, soft_wrap=True, redirect=True) text = "\033[92mfuture is green!\033[0m" console.print(text) text_result = console.export_text(clear=False) assert "future is green!" in text_result html_result = console.export_html() assert "#00ff00" in html_result
def test_rich_console_ex_ansi() -> None: """Validate that ANSI sent to sys.stdout does not become garbage in record.""" print() console = Console(force_terminal=True, record=True, redirect=True) console.print("[green]this from Console.print()[/green]", style="red") proc = run(r'echo -e "\033[31mred\033[0m"') assert proc.returncode == 0 assert "red" in proc.stdout # validate that what rich recorded is the same as what the subprocess produced text = console.export_text(clear=False) assert "red" in text # validate that html export also contains at least the "red" text html = console.export_html(clear=False) assert '<span class="r3">red</span>' in html