Coverage for tests/test_tutorial/test_options_autocompletion/test_tutorial002.py: 100%
18 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
5from typer.testing import CliRunner 1abcdefgh
7from docs_src.options_autocompletion import tutorial002 as mod 1abcdefgh
9runner = CliRunner() 1abcdefgh
12def test_completion(): 1abcdefgh
13 result = subprocess.run( 1abcdefgh
14 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
15 capture_output=True,
16 encoding="utf-8",
17 env={
18 **os.environ,
19 "_TUTORIAL002.PY_COMPLETE": "complete_zsh",
20 "_TYPER_COMPLETE_ARGS": "tutorial002.py --name ",
21 },
22 )
23 assert "Camila" in result.stdout 1abcdefgh
24 assert "Carlos" in result.stdout 1abcdefgh
25 assert "Sebastian" in result.stdout 1abcdefgh
28def test_1(): 1abcdefgh
29 result = runner.invoke(mod.app, ["--name", "Camila"]) 1abcdefgh
30 assert result.exit_code == 0 1abcdefgh
31 assert "Hello Camila" in result.output 1abcdefgh
34def test_script(): 1abcdefgh
35 result = subprocess.run( 1abcdefgh
36 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
37 capture_output=True,
38 encoding="utf-8",
39 )
40 assert "Usage" in result.stdout 1abcdefgh