Coverage for tests/test_compat/test_option_get_help.py: 100%
33 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1import os 1abcdefgh
2import subprocess 1abcdefgh
3import sys 1abcdefgh
5import typer.core 1abcdefgh
6from typer.testing import CliRunner 1abcdefgh
8from tests.assets import compat_click7_8 as mod 1abcdefgh
10runner = CliRunner() 1abcdefgh
13def test_hidden_option(): 1abcdefgh
14 result = runner.invoke(mod.app, ["--help"]) 1abcdefgh
15 assert result.exit_code == 0 1abcdefgh
16 assert "Say hello" in result.output 1abcdefgh
17 assert "--name" not in result.output 1abcdefgh
18 assert "/lastname" in result.output 1abcdefgh
19 assert "TEST_LASTNAME" in result.output 1abcdefgh
20 assert "(dynamic)" in result.output 1abcdefgh
23def test_hidden_option_no_rich(): 1abcdefgh
24 rich = typer.core.rich 1abcdefgh
25 typer.core.rich = None 1abcdefgh
26 result = runner.invoke(mod.app, ["--help"]) 1abcdefgh
27 assert result.exit_code == 0 1abcdefgh
28 assert "Say hello" in result.output 1abcdefgh
29 assert "--name" not in result.output 1abcdefgh
30 assert "/lastname" in result.output 1abcdefgh
31 assert "TEST_LASTNAME" in result.output 1abcdefgh
32 assert "(dynamic)" in result.output 1abcdefgh
33 typer.core.rich = rich 1abcdefgh
36def test_coverage_call(): 1abcdefgh
37 result = runner.invoke(mod.app) 1abcdefgh
38 assert result.exit_code == 0 1abcdefgh
39 assert "Hello John Doe, it seems you have 42" in result.output 1abcdefgh
42def test_completion(): 1abcdefgh
43 result = subprocess.run( 1abcdefgh
44 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
45 capture_output=True,
46 encoding="utf-8",
47 env={
48 **os.environ,
49 "_COMPAT_CLICK7_8.PY_COMPLETE": "complete_zsh",
50 "_TYPER_COMPLETE_ARGS": "compat_click7_8.py --nickname ",
51 },
52 )
53 assert "Jonny" in result.stdout 1abcdefgh