Coverage for tests/test_cli/test_multi_func.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 subprocess 1abcdefgh
2import sys 1abcdefgh
5def test_help(): 1abcdefgh
6 result = subprocess.run( 1abcdefgh
7 [
8 sys.executable,
9 "-m",
10 "coverage",
11 "run",
12 "-m",
13 "typer",
14 "tests/assets/cli/multi_func.py",
15 "run",
16 "--help",
17 ],
18 capture_output=True,
19 encoding="utf-8",
20 )
21 assert "Say hi to someone, by default to the World." in result.stdout 1abcdefgh
24def test_script(): 1abcdefgh
25 result = subprocess.run( 1abcdefgh
26 [
27 sys.executable,
28 "-m",
29 "coverage",
30 "run",
31 "-m",
32 "typer",
33 "tests/assets/cli/multi_func.py",
34 "run",
35 "--name",
36 "Camila",
37 ],
38 capture_output=True,
39 encoding="utf-8",
40 )
41 assert "Hello Camila" in result.stdout 1abcdefgh
44def test_script_func_non_existent(): 1abcdefgh
45 result = subprocess.run( 1abcdefgh
46 [
47 sys.executable,
48 "-m",
49 "coverage",
50 "run",
51 "-m",
52 "typer",
53 "--func",
54 "non_existent",
55 "tests/assets/cli/multi_func.py",
56 "run",
57 "--name",
58 "Camila",
59 ],
60 capture_output=True,
61 encoding="utf-8",
62 )
63 assert "Not a function:" in result.stderr 1abcdefgh
66def test_script_func_not_function(): 1abcdefgh
67 result = subprocess.run( 1abcdefgh
68 [
69 sys.executable,
70 "-m",
71 "coverage",
72 "run",
73 "-m",
74 "typer",
75 "--func",
76 "message",
77 "tests/assets/cli/multi_func.py",
78 "run",
79 "--name",
80 "Camila",
81 ],
82 capture_output=True,
83 encoding="utf-8",
84 )
85 assert "Not a function:" in result.stderr 1abcdefgh
88def test_script_func(): 1abcdefgh
89 result = subprocess.run( 1abcdefgh
90 [
91 sys.executable,
92 "-m",
93 "coverage",
94 "run",
95 "-m",
96 "typer",
97 "--func",
98 "say_stuff",
99 "tests/assets/cli/multi_func.py",
100 "run",
101 ],
102 capture_output=True,
103 encoding="utf-8",
104 )
105 assert "Hello" not in result.stdout 1abcdefgh
106 assert "Stuff" in result.stdout 1abcdefgh