Skip to content

Commit 20567c2

Browse files
authored
{Packaging} Bump argcomplete to 3.5.2 (#30532)
1 parent fd1d6c4 commit 20567c2

File tree

5 files changed

+70
-4
lines changed

5 files changed

+70
-4
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
# --------------------------------------------------------------------------------------------
5+
6+
from unittest import mock, TestCase
7+
8+
from azure.cli.core.mock import DummyCli
9+
from azure.cli.core.util import run_cmd
10+
11+
12+
class ArgcompleteScenarioTest(TestCase):
13+
14+
def argcomplete_env(self, comp_line, comp_point):
15+
return {
16+
'COMP_LINE': comp_line,
17+
'COMP_POINT': comp_point,
18+
'_ARGCOMPLETE': '1',
19+
'_ARGCOMPLETE_IFS': ' ',
20+
'_ARGCOMPLETE_SUPPRESS_SPACE': '0',
21+
'ARGCOMPLETE_USE_TEMPFILES': '1',
22+
'_ARGCOMPLETE_STDOUT_FILENAME': './argcomplete.out', }
23+
24+
def test_completion(self):
25+
import os
26+
import sys
27+
28+
from azure.cli.core.parser import AzCompletionFinder
29+
30+
if sys.platform == 'win32':
31+
self.skipTest('Skip argcomplete test on Windows')
32+
33+
run_cmd(['az'], env=self.argcomplete_env('az account sh', '13'))
34+
with open('argcomplete.out') as f:
35+
self.assertEqual(f.read(), 'show ')
36+
os.remove('argcomplete.out')
37+
38+
run_cmd(['az'], capture_output=True, env=self.argcomplete_env('az account s', '12'))
39+
with open('argcomplete.out') as f:
40+
self.assertEqual(f.read(), 'set show')
41+
os.remove('argcomplete.out')
42+
43+
run_cmd(['az'], env=self.argcomplete_env('az account szzz', '15'))
44+
with open('argcomplete.out') as f:
45+
self.assertFalse(f.read())
46+
os.remove('argcomplete.out')
47+
48+
class MockCompletionFinder(AzCompletionFinder):
49+
def __call__(self, *args, **kwargs):
50+
import sys
51+
return super().__call__(*args, exit_method=sys.exit, **kwargs)
52+
53+
def dummy_completor(*args, **kwargs):
54+
return ['dummystorage']
55+
56+
cli = DummyCli()
57+
# argcomplete uses os._exit to exit, which is also used by pytest. Patch AzCompletionFinder to use sys.exit
58+
# There is no recording for this test case, as completer is mocked.
59+
with mock.patch('azure.cli.core.parser.AzCompletionFinder', MockCompletionFinder):
60+
with mock.patch('azure.cli.core.commands.parameters.get_resource_name_completion_list', lambda _: dummy_completor):
61+
env = self.argcomplete_env('az storage blob list -c test --account-name dumm', '48')
62+
with mock.patch.dict(os.environ, env):
63+
self.assertRaises(SystemExit, cli.invoke, ['az'])
64+
with open('argcomplete.out') as f:
65+
self.assertEqual(f.read(), 'dummystorage ')
66+
os.remove('argcomplete.out')

src/azure-cli-core/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
]
4444

4545
DEPENDENCIES = [
46-
'argcomplete~=3.3.0',
46+
'argcomplete~=3.5.2',
4747
'azure-cli-telemetry==1.1.0.*',
4848
'azure-mgmt-core>=1.2.0,<2',
4949
'cryptography',

src/azure-cli/requirements.py3.Darwin.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
antlr4-python3-runtime==4.13.1
22
applicationinsights==0.11.9
3-
argcomplete==3.3.0
3+
argcomplete==3.5.2
44
asn1crypto==0.24.0
55
azure-appconfiguration==1.7.0
66
azure-batch==14.2.0

src/azure-cli/requirements.py3.Linux.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
antlr4-python3-runtime==4.13.1
22
applicationinsights==0.11.9
3-
argcomplete==3.3.0
3+
argcomplete==3.5.2
44
asn1crypto==0.24.0
55
azure-appconfiguration==1.7.0
66
azure-batch==14.2.0

src/azure-cli/requirements.py3.windows.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
antlr4-python3-runtime==4.13.1
22
applicationinsights==0.11.9
3-
argcomplete==3.3.0
3+
argcomplete==3.5.2
44
asn1crypto==0.24.0
55
azure-appconfiguration==1.7.0
66
azure-batch==14.2.0

0 commit comments

Comments
 (0)