Coverage for tests / test_completion / test_completion_option_colon.py: 100%
116 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-11-18 11:12 +0000
1import os 1abcdefghij
2import subprocess 1abcdefghij
3import sys 1abcdefghij
5from . import colon_example as mod 1abcdefghij
8def test_script(): 1abcdefghij
9 result = subprocess.run( 1abcdefghij
10 [sys.executable, "-m", "coverage", "run", mod.__file__, "--name", "DeadPool"],
11 capture_output=True,
12 encoding="utf-8",
13 )
14 assert result.returncode == 0 1abcdefghij
15 assert "DeadPool" in result.stdout 1abcdefghij
18def test_completion_colon_bash_all(): 1abcdefghij
19 result = subprocess.run( 1abcdefghij
20 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
21 capture_output=True,
22 encoding="utf-8",
23 env={
24 **os.environ,
25 "_COLON_EXAMPLE.PY_COMPLETE": "complete_bash",
26 "COMP_WORDS": "colon_example.py --name ",
27 "COMP_CWORD": "2",
28 },
29 )
30 assert "alpine:hello" in result.stdout 1abcdefghij
31 assert "alpine:latest" in result.stdout 1abcdefghij
32 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefghij
35def test_completion_colon_bash_partial(): 1abcdefghij
36 result = subprocess.run( 1abcdefghij
37 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
38 capture_output=True,
39 encoding="utf-8",
40 env={
41 **os.environ,
42 "_COLON_EXAMPLE.PY_COMPLETE": "complete_bash",
43 "COMP_WORDS": "colon_example.py --name alpine ",
44 "COMP_CWORD": "2",
45 },
46 )
47 assert "alpine:hello" in result.stdout 1abcdefghij
48 assert "alpine:latest" in result.stdout 1abcdefghij
49 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
52def test_completion_colon_bash_single(): 1abcdefghij
53 result = subprocess.run( 1abcdefghij
54 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
55 capture_output=True,
56 encoding="utf-8",
57 env={
58 **os.environ,
59 "_COLON_EXAMPLE.PY_COMPLETE": "complete_bash",
60 "COMP_WORDS": "colon_example.py --name alpine:hell ",
61 "COMP_CWORD": "2",
62 },
63 )
64 assert "alpine:hello" in result.stdout 1abcdefghij
65 assert "alpine:latest" not in result.stdout 1abcdefghij
66 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
69def test_completion_colon_zsh_all(): 1abcdefghij
70 result = subprocess.run( 1abcdefghij
71 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
72 capture_output=True,
73 encoding="utf-8",
74 env={
75 **os.environ,
76 "_COLON_EXAMPLE.PY_COMPLETE": "complete_zsh",
77 "_TYPER_COMPLETE_ARGS": "colon_example.py --name ",
78 },
79 )
80 assert "alpine\\\\:hello" in result.stdout 1abcdefghij
81 assert "fake image\\\\: for testing" in result.stdout 1abcdefghij
82 assert "alpine\\\\:latest" in result.stdout 1abcdefghij
83 assert "latest alpine image" in result.stdout 1abcdefghij
84 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout 1abcdefghij
87def test_completion_colon_zsh_partial(): 1abcdefghij
88 result = subprocess.run( 1abcdefghij
89 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
90 capture_output=True,
91 encoding="utf-8",
92 env={
93 **os.environ,
94 "_COLON_EXAMPLE.PY_COMPLETE": "complete_zsh",
95 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
96 },
97 )
98 assert "alpine\\\\:hello" in result.stdout 1abcdefghij
99 assert "fake image\\\\: for testing" in result.stdout 1abcdefghij
100 assert "alpine\\\\:latest" in result.stdout 1abcdefghij
101 assert "latest alpine image" in result.stdout 1abcdefghij
102 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
105def test_completion_colon_zsh_single(): 1abcdefghij
106 result = subprocess.run( 1abcdefghij
107 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
108 capture_output=True,
109 encoding="utf-8",
110 env={
111 **os.environ,
112 "_COLON_EXAMPLE.PY_COMPLETE": "complete_zsh",
113 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
114 },
115 )
116 assert "alpine\\\\:hello" in result.stdout 1abcdefghij
117 assert "fake image\\\\: for testing" in result.stdout 1abcdefghij
118 assert "alpine\\\\:latest" not in result.stdout 1abcdefghij
119 assert "latest alpine image" not in result.stdout 1abcdefghij
120 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
123def test_completion_colon_powershell_all(): 1abcdefghij
124 result = subprocess.run( 1abcdefghij
125 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
126 capture_output=True,
127 encoding="utf-8",
128 env={
129 **os.environ,
130 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
131 "_TYPER_COMPLETE_ARGS": "colon_example.py --name ",
132 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "",
133 },
134 )
135 assert "alpine:hello" in result.stdout 1abcdefghij
136 assert "fake image: for testing" in result.stdout 1abcdefghij
137 assert "alpine:latest" in result.stdout 1abcdefghij
138 assert "latest alpine image" in result.stdout 1abcdefghij
139 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefghij
142def test_completion_colon_powershell_partial(): 1abcdefghij
143 result = subprocess.run( 1abcdefghij
144 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
145 capture_output=True,
146 encoding="utf-8",
147 env={
148 **os.environ,
149 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
150 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
151 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine",
152 },
153 )
154 assert "alpine:hello" in result.stdout 1abcdefghij
155 assert "fake image: for testing" in result.stdout 1abcdefghij
156 assert "alpine:latest" in result.stdout 1abcdefghij
157 assert "latest alpine image" in result.stdout 1abcdefghij
158 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
161def test_completion_colon_powershell_single(): 1abcdefghij
162 result = subprocess.run( 1abcdefghij
163 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
164 capture_output=True,
165 encoding="utf-8",
166 env={
167 **os.environ,
168 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
169 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
170 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine:hell",
171 },
172 )
173 assert "alpine:hello" in result.stdout 1abcdefghij
174 assert "fake image: for testing" in result.stdout 1abcdefghij
175 assert "alpine:latest" not in result.stdout 1abcdefghij
176 assert "latest alpine image" not in result.stdout 1abcdefghij
177 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
180def test_completion_powershell_option_equals_value() -> None: 1abcdefghij
181 result = subprocess.run( 1abcdefghij
182 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
183 capture_output=True,
184 encoding="utf-8",
185 env={
186 **os.environ,
187 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
188 "_TYPER_COMPLETE_ARGS": "colon_example.py --name=alpine",
189 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "--name=alpine",
190 },
191 )
192 assert "alpine:hello" in result.stdout 1abcdefghij
193 assert "alpine:latest" in result.stdout 1abcdefghij
194 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
197def test_completion_powershell_option_equals_only() -> None: 1abcdefghij
198 result = subprocess.run( 1abcdefghij
199 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
200 capture_output=True,
201 encoding="utf-8",
202 env={
203 **os.environ,
204 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
205 "_TYPER_COMPLETE_ARGS": "colon_example.py --name=",
206 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "=",
207 },
208 )
209 assert result.returncode == 0 1abcdefghij
210 assert result.stdout.strip() == "" 1abcdefghij
213def test_completion_colon_pwsh_all(): 1abcdefghij
214 result = subprocess.run( 1abcdefghij
215 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
216 capture_output=True,
217 encoding="utf-8",
218 env={
219 **os.environ,
220 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
221 "_TYPER_COMPLETE_ARGS": "colon_example.py --name",
222 },
223 )
225 assert "alpine:hello" in result.stdout 1abcdefghij
226 assert "fake image: for testing" in result.stdout 1abcdefghij
227 assert "alpine:latest" in result.stdout 1abcdefghij
228 assert "latest alpine image" in result.stdout 1abcdefghij
229 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefghij
232def test_completion_colon_pwsh_partial(): 1abcdefghij
233 result = subprocess.run( 1abcdefghij
234 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
235 capture_output=True,
236 encoding="utf-8",
237 env={
238 **os.environ,
239 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
240 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
241 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine",
242 },
243 )
244 assert "alpine:hello" in result.stdout 1abcdefghij
245 assert "fake image: for testing" in result.stdout 1abcdefghij
246 assert "alpine:latest" in result.stdout 1abcdefghij
247 assert "latest alpine image" in result.stdout 1abcdefghij
248 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
251def test_completion_colon_pwsh_single(): 1abcdefghij
252 result = subprocess.run( 1abcdefghij
253 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
254 capture_output=True,
255 encoding="utf-8",
256 env={
257 **os.environ,
258 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
259 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
260 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine:hell",
261 },
262 )
263 assert "alpine:hello" in result.stdout 1abcdefghij
264 assert "fake image: for testing" in result.stdout 1abcdefghij
265 assert "alpine:latest" not in result.stdout 1abcdefghij
266 assert "latest alpine image" not in result.stdout 1abcdefghij
267 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
270def test_completion_colon_fish_all(): 1abcdefghij
271 result = subprocess.run( 1abcdefghij
272 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
273 capture_output=True,
274 encoding="utf-8",
275 env={
276 **os.environ,
277 "_COLON_EXAMPLE.PY_COMPLETE": "complete_fish",
278 "_TYPER_COMPLETE_ARGS": "colon_example.py --name ",
279 "_TYPER_COMPLETE_FISH_ACTION": "get-args",
280 },
281 )
282 assert "alpine:hello" in result.stdout 1abcdefghij
283 assert "fake image: for testing" in result.stdout 1abcdefghij
284 assert "alpine:latest" in result.stdout 1abcdefghij
285 assert "latest alpine image" in result.stdout 1abcdefghij
286 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefghij
289def test_completion_colon_fish_partial(): 1abcdefghij
290 result = subprocess.run( 1abcdefghij
291 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
292 capture_output=True,
293 encoding="utf-8",
294 env={
295 **os.environ,
296 "_COLON_EXAMPLE.PY_COMPLETE": "complete_fish",
297 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
298 "_TYPER_COMPLETE_FISH_ACTION": "get-args",
299 },
300 )
301 assert "alpine:hello" in result.stdout 1abcdefghij
302 assert "fake image: for testing" in result.stdout 1abcdefghij
303 assert "alpine:latest" in result.stdout 1abcdefghij
304 assert "latest alpine image" in result.stdout 1abcdefghij
305 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij
308def test_completion_colon_fish_single(): 1abcdefghij
309 result = subprocess.run( 1abcdefghij
310 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
311 capture_output=True,
312 encoding="utf-8",
313 env={
314 **os.environ,
315 "_COLON_EXAMPLE.PY_COMPLETE": "complete_fish",
316 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
317 "_TYPER_COMPLETE_FISH_ACTION": "get-args",
318 },
319 )
320 assert "alpine:hello" in result.stdout 1abcdefghij
321 assert "fake image: for testing" in result.stdout 1abcdefghij
322 assert "alpine:latest" not in result.stdout 1abcdefghij
323 assert "latest alpine image" not in result.stdout 1abcdefghij
324 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefghij