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-09 00:15 +0000

1import os 1abcdefg

2import subprocess 1abcdefg

3import sys 1abcdefg

4 

5from . import colon_example as mod 1abcdefg

6 

7 

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

16 

17 

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

33 

34 

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

50 

51 

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

67 

68 

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 "fake image\\\\: for testing" in result.stdout 1abcdefg

82 assert "alpine\\\\:latest" in result.stdout 1abcdefg

83 assert "latest alpine image" in result.stdout 1abcdefg

84 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg

85 

86 

87def test_completion_colon_zsh_partial(): 1abcdefg

88 result = subprocess.run( 1abcdefg

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 1abcdefg

99 assert "fake image\\\\: for testing" in result.stdout 1abcdefg

100 assert "alpine\\\\:latest" in result.stdout 1abcdefg

101 assert "latest alpine image" in result.stdout 1abcdefg

102 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

103 

104 

105def test_completion_colon_zsh_single(): 1abcdefg

106 result = subprocess.run( 1abcdefg

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 1abcdefg

117 assert "fake image\\\\: for testing" in result.stdout 1abcdefg

118 assert "alpine\\\\:latest" not in result.stdout 1abcdefg

119 assert "latest alpine image" not in result.stdout 1abcdefg

120 assert "nvidia/cuda\\\\:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

121 

122 

123def test_completion_colon_powershell_all(): 1abcdefg

124 result = subprocess.run( 1abcdefg

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 1abcdefg

136 assert "fake image: for testing" in result.stdout 1abcdefg

137 assert "alpine:latest" in result.stdout 1abcdefg

138 assert "latest alpine image" in result.stdout 1abcdefg

139 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg

140 

141 

142def test_completion_colon_powershell_partial(): 1abcdefg

143 result = subprocess.run( 1abcdefg

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 1abcdefg

155 assert "fake image: for testing" in result.stdout 1abcdefg

156 assert "alpine:latest" in result.stdout 1abcdefg

157 assert "latest alpine image" in result.stdout 1abcdefg

158 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

159 

160 

161def test_completion_colon_powershell_single(): 1abcdefg

162 result = subprocess.run( 1abcdefg

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 1abcdefg

174 assert "fake image: for testing" in result.stdout 1abcdefg

175 assert "alpine:latest" not in result.stdout 1abcdefg

176 assert "latest alpine image" not in result.stdout 1abcdefg

177 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

178 

179 

180def test_completion_powershell_option_equals_value() -> None: 1abcdefg

181 result = subprocess.run( 1abcdefg

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 1abcdefg

193 assert "alpine:latest" in result.stdout 1abcdefg

194 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

195 

196 

197def test_completion_powershell_option_equals_only() -> None: 1abcdefg

198 result = subprocess.run( 1abcdefg

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 1abcdefg

210 assert result.stdout.strip() == "" 1abcdefg

211 

212 

213def test_completion_colon_pwsh_all(): 1abcdefg

214 result = subprocess.run( 1abcdefg

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 ) 

224 

225 assert "alpine:hello" in result.stdout 1abcdefg

226 assert "fake image: for testing" in result.stdout 1abcdefg

227 assert "alpine:latest" in result.stdout 1abcdefg

228 assert "latest alpine image" in result.stdout 1abcdefg

229 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg

230 

231 

232def test_completion_colon_pwsh_partial(): 1abcdefg

233 result = subprocess.run( 1abcdefg

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 1abcdefg

245 assert "fake image: for testing" in result.stdout 1abcdefg

246 assert "alpine:latest" in result.stdout 1abcdefg

247 assert "latest alpine image" in result.stdout 1abcdefg

248 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

249 

250 

251def test_completion_colon_pwsh_single(): 1abcdefg

252 result = subprocess.run( 1abcdefg

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 1abcdefg

264 assert "fake image: for testing" in result.stdout 1abcdefg

265 assert "alpine:latest" not in result.stdout 1abcdefg

266 assert "latest alpine image" not in result.stdout 1abcdefg

267 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

268 

269 

270def test_completion_colon_fish_all(): 1abcdefg

271 result = subprocess.run( 1abcdefg

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 1abcdefg

283 assert "fake image: for testing" in result.stdout 1abcdefg

284 assert "alpine:latest" in result.stdout 1abcdefg

285 assert "latest alpine image" in result.stdout 1abcdefg

286 assert "nvidia/cuda:10.0-devel-ubuntu18.04" in result.stdout 1abcdefg

287 

288 

289def test_completion_colon_fish_partial(): 1abcdefg

290 result = subprocess.run( 1abcdefg

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 1abcdefg

302 assert "fake image: for testing" in result.stdout 1abcdefg

303 assert "alpine:latest" in result.stdout 1abcdefg

304 assert "latest alpine image" in result.stdout 1abcdefg

305 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg

306 

307 

308def test_completion_colon_fish_single(): 1abcdefg

309 result = subprocess.run( 1abcdefg

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 1abcdefg

321 assert "fake image: for testing" in result.stdout 1abcdefg

322 assert "alpine:latest" not in result.stdout 1abcdefg

323 assert "latest alpine image" not in result.stdout 1abcdefg

324 assert "nvidia/cuda:10.0-devel-ubuntu18.04" not in result.stdout 1abcdefg