Coverage for tests / test_completion / test_completion_option_colon.py: 100%
68 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-03-26 21:46 +0000
1import os 1abcdefg
2import subprocess 1abcdefg
3import sys 1abcdefg
5from . import colon_example as mod 1abcdefg
8def test_script(): 1abcdefg
9 result = subprocess.run( 1abcdefg
10 [sys.executable, "-m", "coverage", "run", mod.__file__, "--name", "DeadPool"],
11 capture_output=True,
12 encoding="utf-8",
13 )
14 assert result.returncode == 0 1abcdefg
15 assert "DeadPool" in result.stdout 1abcdefg
18def test_completion_colon_bash_all(): 1abcdefg
19 result = subprocess.run( 1abcdefg
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 1abcdefg
31 assert "alpine:latest" in result.stdout 1abcdefg
32 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg
35def test_completion_colon_bash_partial(): 1abcdefg
36 result = subprocess.run( 1abcdefg
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 1abcdefg
48 assert "alpine:latest" in result.stdout 1abcdefg
49 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
52def test_completion_colon_bash_single(): 1abcdefg
53 result = subprocess.run( 1abcdefg
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 1abcdefg
65 assert "alpine:latest" not in result.stdout 1abcdefg
66 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
69def test_completion_colon_zsh_all(): 1abcdefg
70 result = subprocess.run( 1abcdefg
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 1abcdefg
81 assert "alpine\\\\:latest" in result.stdout 1abcdefg
82 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg
85def test_completion_colon_zsh_partial(): 1abcdefg
86 result = subprocess.run( 1abcdefg
87 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
88 capture_output=True,
89 encoding="utf-8",
90 env={
91 **os.environ,
92 "_COLON_EXAMPLE.PY_COMPLETE": "complete_zsh",
93 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
94 },
95 )
96 assert "alpine\\\\:hello" in result.stdout 1abcdefg
97 assert "alpine\\\\:latest" in result.stdout 1abcdefg
98 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
101def test_completion_colon_zsh_single(): 1abcdefg
102 result = subprocess.run( 1abcdefg
103 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
104 capture_output=True,
105 encoding="utf-8",
106 env={
107 **os.environ,
108 "_COLON_EXAMPLE.PY_COMPLETE": "complete_zsh",
109 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
110 },
111 )
112 assert "alpine\\\\:hello" in result.stdout 1abcdefg
113 assert "alpine\\\\:latest" not in result.stdout 1abcdefg
114 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
117def test_completion_colon_powershell_all(): 1abcdefg
118 result = subprocess.run( 1abcdefg
119 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
120 capture_output=True,
121 encoding="utf-8",
122 env={
123 **os.environ,
124 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
125 "_TYPER_COMPLETE_ARGS": "colon_example.py --name ",
126 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "",
127 },
128 )
129 assert "alpine:hello" in result.stdout 1abcdefg
130 assert "alpine:latest" in result.stdout 1abcdefg
131 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg
134def test_completion_colon_powershell_partial(): 1abcdefg
135 result = subprocess.run( 1abcdefg
136 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
137 capture_output=True,
138 encoding="utf-8",
139 env={
140 **os.environ,
141 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
142 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
143 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine",
144 },
145 )
146 assert "alpine:hello" in result.stdout 1abcdefg
147 assert "alpine:latest" in result.stdout 1abcdefg
148 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
151def test_completion_colon_powershell_single(): 1abcdefg
152 result = subprocess.run( 1abcdefg
153 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
154 capture_output=True,
155 encoding="utf-8",
156 env={
157 **os.environ,
158 "_COLON_EXAMPLE.PY_COMPLETE": "complete_powershell",
159 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
160 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine:hell",
161 },
162 )
163 assert "alpine:hello" in result.stdout 1abcdefg
164 assert "alpine:latest" not in result.stdout 1abcdefg
165 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
168def test_completion_colon_pwsh_all(): 1abcdefg
169 result = subprocess.run( 1abcdefg
170 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
171 capture_output=True,
172 encoding="utf-8",
173 env={
174 **os.environ,
175 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
176 "_TYPER_COMPLETE_ARGS": "colon_example.py --name",
177 },
178 )
180 assert "alpine:hello" in result.stdout 1abcdefg
181 assert "alpine:latest" in result.stdout 1abcdefg
182 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg
185def test_completion_colon_pwsh_partial(): 1abcdefg
186 result = subprocess.run( 1abcdefg
187 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
188 capture_output=True,
189 encoding="utf-8",
190 env={
191 **os.environ,
192 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
193 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine",
194 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine",
195 },
196 )
197 assert "alpine:hello" in result.stdout 1abcdefg
198 assert "alpine:latest" in result.stdout 1abcdefg
199 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
202def test_completion_colon_pwsh_single(): 1abcdefg
203 result = subprocess.run( 1abcdefg
204 [sys.executable, "-m", "coverage", "run", mod.__file__, " "],
205 capture_output=True,
206 encoding="utf-8",
207 env={
208 **os.environ,
209 "_COLON_EXAMPLE.PY_COMPLETE": "complete_pwsh",
210 "_TYPER_COMPLETE_ARGS": "colon_example.py --name alpine:hell",
211 "_TYPER_COMPLETE_WORD_TO_COMPLETE": "alpine:hell",
212 },
213 )
214 assert "alpine:hello" in result.stdout 1abcdefg
215 assert "alpine:latest" not in result.stdout 1abcdefg
216 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg
219# TODO: tests for complete_fish