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