Coverage for tests/test_tutorial/test_options_autocompletion/test_tutorial007.py: 100%
19 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 tutorial007 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 "_TUTORIAL007.PY_COMPLETE": "complete_zsh",
20 "_TYPER_COMPLETE_ARGS": "tutorial007.py --name Sebastian --name ",
21 },
22 )
23 assert '"Camila":"The reader of books."' in result.stdout 1abcdefgh
24 assert '"Carlos":"The writer of scripts."' in result.stdout 1abcdefgh
25 assert '"Sebastian":"The type hints guy."' not in result.stdout 1abcdefgh
28def test_1(): 1abcdefgh
29 result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) 1abcdefgh
30 assert result.exit_code == 0 1abcdefgh
31 assert "Hello Camila" in result.output 1abcdefgh
32 assert "Hello Sebastian" in result.output 1abcdefgh
35def test_script(): 1abcdefgh
36 result = subprocess.run( 1abcdefgh
37 [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"],
38 capture_output=True,
39 encoding="utf-8",
40 )
41 assert "Usage" in result.stdout 1abcdefgh