Skip to content

Commit

Permalink
{Packaging} Bump argcomplete to 3.5.2 (#30532)
Browse files Browse the repository at this point in the history
  • Loading branch information
bebound authored Jan 7, 2025
1 parent fd1d6c4 commit 20567c2
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 4 deletions.
66 changes: 66 additions & 0 deletions src/azure-cli-core/azure/cli/core/tests/test_argcomplete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from unittest import mock, TestCase

from azure.cli.core.mock import DummyCli
from azure.cli.core.util import run_cmd


class ArgcompleteScenarioTest(TestCase):

def argcomplete_env(self, comp_line, comp_point):
return {
'COMP_LINE': comp_line,
'COMP_POINT': comp_point,
'_ARGCOMPLETE': '1',
'_ARGCOMPLETE_IFS': ' ',
'_ARGCOMPLETE_SUPPRESS_SPACE': '0',
'ARGCOMPLETE_USE_TEMPFILES': '1',
'_ARGCOMPLETE_STDOUT_FILENAME': './argcomplete.out', }

def test_completion(self):
import os
import sys

from azure.cli.core.parser import AzCompletionFinder

if sys.platform == 'win32':
self.skipTest('Skip argcomplete test on Windows')

run_cmd(['az'], env=self.argcomplete_env('az account sh', '13'))
with open('argcomplete.out') as f:
self.assertEqual(f.read(), 'show ')
os.remove('argcomplete.out')

run_cmd(['az'], capture_output=True, env=self.argcomplete_env('az account s', '12'))
with open('argcomplete.out') as f:
self.assertEqual(f.read(), 'set show')
os.remove('argcomplete.out')

run_cmd(['az'], env=self.argcomplete_env('az account szzz', '15'))
with open('argcomplete.out') as f:
self.assertFalse(f.read())
os.remove('argcomplete.out')

class MockCompletionFinder(AzCompletionFinder):
def __call__(self, *args, **kwargs):
import sys
return super().__call__(*args, exit_method=sys.exit, **kwargs)

def dummy_completor(*args, **kwargs):
return ['dummystorage']

cli = DummyCli()
# argcomplete uses os._exit to exit, which is also used by pytest. Patch AzCompletionFinder to use sys.exit
# There is no recording for this test case, as completer is mocked.
with mock.patch('azure.cli.core.parser.AzCompletionFinder', MockCompletionFinder):
with mock.patch('azure.cli.core.commands.parameters.get_resource_name_completion_list', lambda _: dummy_completor):
env = self.argcomplete_env('az storage blob list -c test --account-name dumm', '48')
with mock.patch.dict(os.environ, env):
self.assertRaises(SystemExit, cli.invoke, ['az'])
with open('argcomplete.out') as f:
self.assertEqual(f.read(), 'dummystorage ')
os.remove('argcomplete.out')
2 changes: 1 addition & 1 deletion src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
]

DEPENDENCIES = [
'argcomplete~=3.3.0',
'argcomplete~=3.5.2',
'azure-cli-telemetry==1.1.0.*',
'azure-mgmt-core>=1.2.0,<2',
'cryptography',
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
antlr4-python3-runtime==4.13.1
applicationinsights==0.11.9
argcomplete==3.3.0
argcomplete==3.5.2
asn1crypto==0.24.0
azure-appconfiguration==1.7.0
azure-batch==14.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
antlr4-python3-runtime==4.13.1
applicationinsights==0.11.9
argcomplete==3.3.0
argcomplete==3.5.2
asn1crypto==0.24.0
azure-appconfiguration==1.7.0
azure-batch==14.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
antlr4-python3-runtime==4.13.1
applicationinsights==0.11.9
argcomplete==3.3.0
argcomplete==3.5.2
asn1crypto==0.24.0
azure-appconfiguration==1.7.0
azure-batch==14.2.0
Expand Down

0 comments on commit 20567c2

Please sign in to comment.