Coverage for tests / test_tutorial / test_printing / test_tutorial005.py: 100%
20 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
1import subprocess 1abcdefghij
2import sys 1abcdefghij
4from typer.testing import CliRunner 1abcdefghij
6import docs_src.printing.tutorial005 as mod 1abcdefghij
7from tests.utils import normalize_rich_output 1abcdefghij
9app = mod.app 1abcdefghij
11runner = CliRunner() 1abcdefghij
14def test_good_true(): 1abcdefghij
15 result = runner.invoke(app, color=True) 1abcdefghij
16 assert result.exit_code == 0 1abcdefghij
18 # Replace all Rich formatting with `*` characters
19 normalized_output = normalize_rich_output(result.output) 1abcdefghij
21 assert "everything is *good*" in normalized_output 1abcdefghij
22 # We don't check exact colors here, just that text has formatting
25def test_good_false(): 1abcdefghij
26 result = runner.invoke(app, ["--no-good"], color=True) 1abcdefghij
27 assert result.exit_code == 0 1abcdefghij
29 # Replace all Rich formatting with `*` characters
30 normalized_output = normalize_rich_output(result.output) 1abcdefghij
32 assert "everything is *bad*" in normalized_output 1abcdefghij
33 # We don't check exact colors here, just that text has formatting
36def test_script(): 1abcdefghij
37 result = subprocess.run( 1abcdefghij
38 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
39 capture_output=True,
40 encoding="utf-8",
41 )
42 assert "Usage" in result.stdout 1abcdefghij