Coverage for tests / test_tutorial / test_printing / test_tutorial003.py: 100%
15 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-09 12:36 +0000
1import subprocess 1abcdefgh
2import sys 1abcdefgh
4from typer.testing import CliRunner 1abcdefgh
6import docs_src.printing.tutorial003_py39 as mod 1abcdefgh
7from tests.utils import normalize_rich_output 1abcdefgh
9app = mod.app 1abcdefgh
11runner = CliRunner() 1abcdefgh
14def test_cli(): 1abcdefgh
15 result = runner.invoke(app) 1abcdefgh
17 # Replace all Rich formatting with `*` characters
18 normalized_output = normalize_rich_output(result.output) 1abcdefgh
20 assert result.exit_code == 0 1abcdefgh
21 assert ( 1abcdefgh
22 "*\n* Name * Item *\n*\n* Rick * Portal Gun *\n* Morty * Plumbus *\n*\n"
23 ) in normalized_output
26def test_script(): 1abcdefgh
27 result = subprocess.run( 1abcdefgh
28 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
29 capture_output=True,
30 encoding="utf-8",
31 )
32 assert "Usage" in result.stdout 1abcdefgh