Coverage for tests/test_tutorial/test_arguments/test_help/test_tutorial001.py: 100%
33 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-12-19 20:29 +0000
1import subprocess 1abcdefghi
2import sys 1abcdefghi
4import pytest 1abcdefghi
5import typer 1abcdefghi
6import typer.core 1abcdefghi
7from typer.testing import CliRunner 1abcdefghi
9from docs_src.arguments.help import tutorial001 as mod 1abcdefghi
11runner = CliRunner() 1abcdefghi
12app = mod.app 1abcdefghi
15def test_help(): 1abcdefghi
16 result = runner.invoke(app, ["--help"]) 1abcdefghi
17 assert result.exit_code == 0 1abcdefghi
18 assert "[OPTIONS] NAME" in result.output 1abcdefghi
19 assert "Arguments" in result.output 1abcdefghi
20 assert "NAME" in result.output 1abcdefghi
21 assert "The name of the user to greet" in result.output 1abcdefghi
22 assert "[required]" in result.output 1abcdefghi
25def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): 1abcdefghi
26 monkeypatch.setattr(typer.core, "HAS_RICH", False) 1abcdefghi
27 result = runner.invoke(app, ["--help"]) 1abcdefghi
28 assert result.exit_code == 0 1abcdefghi
29 assert "[OPTIONS] NAME" in result.output 1abcdefghi
30 assert "Arguments" in result.output 1abcdefghi
31 assert "NAME" in result.output 1abcdefghi
32 assert "The name of the user to greet" in result.output 1abcdefghi
33 assert "[required]" in result.output 1abcdefghi
36def test_call_arg(): 1abcdefghi
37 result = runner.invoke(app, ["Camila"]) 1abcdefghi
38 assert result.exit_code == 0 1abcdefghi
39 assert "Hello Camila" in result.output 1abcdefghi
42def test_script(): 1abcdefghi
43 result = subprocess.run( 1abcdefghi
44 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
45 capture_output=True,
46 encoding="utf-8",
47 )
48 assert "Usage" in result.stdout 1abcdefghi