14
14
# dropping support for Python 3.7.
15
15
Protocol = object
16
16
17
-
18
17
COMPLETION_FOR_SUPPORTED_SHELLS_TESTS = (
19
18
(
20
19
"bash" ,
@@ -133,6 +132,7 @@ def __call__(
133
132
cword : str ,
134
133
cwd : Union [Path , str , None ] = None ,
135
134
include_env : bool = True ,
135
+ expect_error : bool = True ,
136
136
) -> Tuple [TestPipResult , PipTestEnvironment ]:
137
137
...
138
138
@@ -149,6 +149,7 @@ def do_autocomplete(
149
149
cword : str ,
150
150
cwd : Union [Path , str , None ] = None ,
151
151
include_env : bool = True ,
152
+ expect_error : bool = True ,
152
153
) -> Tuple [TestPipResult , PipTestEnvironment ]:
153
154
if include_env :
154
155
autocomplete_script .environ ["COMP_WORDS" ] = words
@@ -158,7 +159,7 @@ def do_autocomplete(
158
159
"-c" ,
159
160
"from pip._internal.cli.autocompletion import autocomplete;"
160
161
"autocomplete()" ,
161
- expect_error = True ,
162
+ expect_error = expect_error ,
162
163
cwd = cwd ,
163
164
)
164
165
@@ -176,6 +177,17 @@ def test_completion_for_unknown_shell(autocomplete_script: PipTestEnvironment) -
176
177
assert error_msg in result .stderr , "tests for an unknown shell failed"
177
178
178
179
180
+ def test_completion_without_env_vars (autocomplete : DoAutocomplete ) -> None :
181
+ """
182
+ Test getting completion <path> after options in command
183
+ given absolute path
184
+ """
185
+ res , env = autocomplete (
186
+ words = "pip install " , cword = "" , include_env = False , expect_error = False
187
+ )
188
+ assert res .stdout == "" , "autocomplete function did not complete"
189
+
190
+
179
191
def test_completion_alone (autocomplete_script : PipTestEnvironment ) -> None :
180
192
"""
181
193
Test getting completion for none shell, just pip completion
@@ -417,16 +429,3 @@ def test_completion_uses_same_executable_name(
417
429
expect_stderr = deprecated_python ,
418
430
)
419
431
assert executable_name in result .stdout
420
-
421
-
422
- def test_completion_without_env_vars (autocomplete : DoAutocomplete ) -> None :
423
- """
424
- Test getting completion <path> after options in command
425
- given absolute path
426
- """
427
- res , env = autocomplete (
428
- words = "pip install " ,
429
- cword = "" ,
430
- include_env = False ,
431
- )
432
- assert res .stdout == ""
0 commit comments