Coverage for tests/test_completion/test_completion_option_colon.py: 100%

68 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-13 11:07 +0000

1import os 1abcdefgh

2import subprocess 1abcdefgh

3import sys 1abcdefgh

4 

5from . import colon_example as mod 1abcdefgh

6 

7 

8def test_script(): 1abcdefgh

9 result = subprocess.run( 1abcdefgh

10 [sys.executable, "-m", "coverage", "run", mod.__file__, "--name", "DeadPool"], 

11 capture_output=True, 

12 encoding="utf-8", 

13 ) 

14 assert result.returncode == 0 1abcdefgh

15 assert "DeadPool" in result.stdout 1abcdefgh

16 

17 

18def test_completion_colon_bash_all(): 1abcdefgh

19 result = subprocess.run( 1abcdefgh

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

31 assert "alpine:latest" in result.stdout 1abcdefgh

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

33 

34 

35def test_completion_colon_bash_partial(): 1abcdefgh

36 result = subprocess.run( 1abcdefgh

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

48 assert "alpine:latest" in result.stdout 1abcdefgh

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

50 

51 

52def test_completion_colon_bash_single(): 1abcdefgh

53 result = subprocess.run( 1abcdefgh

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

65 assert "alpine:latest" not in result.stdout 1abcdefgh

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

67 

68 

69def test_completion_colon_zsh_all(): 1abcdefgh

70 result = subprocess.run( 1abcdefgh

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

81 assert "alpine\\\\:latest" in result.stdout 1abcdefgh

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

83 

84 

85def test_completion_colon_zsh_partial(): 1abcdefgh

86 result = subprocess.run( 1abcdefgh

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

97 assert "alpine\\\\:latest" in result.stdout 1abcdefgh

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

99 

100 

101def test_completion_colon_zsh_single(): 1abcdefgh

102 result = subprocess.run( 1abcdefgh

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

113 assert "alpine\\\\:latest" not in result.stdout 1abcdefgh

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

115 

116 

117def test_completion_colon_powershell_all(): 1abcdefgh

118 result = subprocess.run( 1abcdefgh

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

130 assert "alpine:latest" in result.stdout 1abcdefgh

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

132 

133 

134def test_completion_colon_powershell_partial(): 1abcdefgh

135 result = subprocess.run( 1abcdefgh

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

147 assert "alpine:latest" in result.stdout 1abcdefgh

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

149 

150 

151def test_completion_colon_powershell_single(): 1abcdefgh

152 result = subprocess.run( 1abcdefgh

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

164 assert "alpine:latest" not in result.stdout 1abcdefgh

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

166 

167 

168def test_completion_colon_pwsh_all(): 1abcdefgh

169 result = subprocess.run( 1abcdefgh

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 ) 

179 

180 assert "alpine:hello" in result.stdout 1abcdefgh

181 assert "alpine:latest" in result.stdout 1abcdefgh

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

183 

184 

185def test_completion_colon_pwsh_partial(): 1abcdefgh

186 result = subprocess.run( 1abcdefgh

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

198 assert "alpine:latest" in result.stdout 1abcdefgh

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

200 

201 

202def test_completion_colon_pwsh_single(): 1abcdefgh

203 result = subprocess.run( 1abcdefgh

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

215 assert "alpine:latest" not in result.stdout 1abcdefgh

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

217 

218 

219# TODO: tests for complete_fish