-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Packaging] Support Python 3.11 #26923
Changes from all commits
edf18bd
e2852ec
d0421af
c5dec5a
f91ee23
db4341f
7a0c285
265fb6c
70a89dc
f2dc5e7
890df61
97beb14
ae79bd7
9532240
5a3d9f2
957f19b
0e92cb2
edea742
7e19a72
36d8dc4
87d3e90
952aac6
b5fedff
f4cf181
c8109ff
ba4951a
f87722c
f2baaba
6936dc5
8b7a8c3
d0887b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -298,10 +298,10 @@ def _check_index(): | |||
loader.load_command_table(["hello", "mod-only"]) | ||||
_check_index() | ||||
|
||||
with mock.patch("azure.cli.core.__version__", "2.7.0"), mock.patch.object(cli.cloud, "profile", "2019-03-01-hybrid"): | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test fails in Python 3.11:
I found a similar issue scikit-hep/pyhf#2143. Switching to After further debugging
Git blaming
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great work, I have never considered that this error is related to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured this out. The actual cause is In 3.10, mock use its own In 3.11, it uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this conversation open as a TODO item. I feel there should be a way to patch |
||||
with mock.patch.object(cli.cloud, "profile", "2019-03-01-hybrid"): | ||||
def update_and_check_index(): | ||||
loader.load_command_table(["hello", "mod-only"]) | ||||
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_VERSION], "2.7.0") | ||||
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_VERSION], __version__) | ||||
self.assertEqual(INDEX[CommandIndex._COMMAND_INDEX_CLOUD_PROFILE], "2019-03-01-hybrid") | ||||
self.assertDictEqual(INDEX[CommandIndex._COMMAND_INDEX], self.expected_command_index) | ||||
|
||||
|
@@ -395,6 +395,7 @@ def update_and_check_index(): | |||
@mock.patch('azure.cli.core.extension.get_extension_modname', _mock_get_extension_modname) | ||||
@mock.patch('azure.cli.core.extension.get_extensions', _mock_get_extensions) | ||||
def test_command_index_always_loaded_extensions(self): | ||||
import azure | ||||
from azure.cli.core import CommandIndex | ||||
|
||||
cli = DummyCli() | ||||
|
@@ -403,14 +404,14 @@ def test_command_index_always_loaded_extensions(self): | |||
index.invalidate() | ||||
|
||||
# Test azext_always_loaded is loaded when command index is rebuilt | ||||
with mock.patch('azure.cli.core.ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']): | ||||
with mock.patch.object(azure.cli.core,'ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']): | ||||
loader.load_command_table(["hello", "mod-only"]) | ||||
self.assertEqual(TestCommandRegistration.test_hook, "FAKE_HANDLER") | ||||
|
||||
TestCommandRegistration.test_hook = [] | ||||
|
||||
# Test azext_always_loaded is loaded when command index is used | ||||
with mock.patch('azure.cli.core.ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']): | ||||
with mock.patch.object(azure.cli.core,'ALWAYS_LOADED_EXTENSIONS', ['azext_always_loaded']): | ||||
loader.load_command_table(["hello", "mod-only"]) | ||||
self.assertEqual(TestCommandRegistration.test_hook, "FAKE_HANDLER") | ||||
|
||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,6 @@ def test_help_loads(self): | |
except SystemExit: | ||
pass | ||
cmd_tbl = cli.invocation.commands_loader.command_table | ||
cli.invocation.parser.load_command_table(cli.invocation.commands_loader) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix
The command table is build in |
||
for cmd in cmd_tbl: | ||
try: | ||
cmd_tbl[cmd].loader.command_name = cmd | ||
|
@@ -140,7 +139,6 @@ def test_help_loads(self): | |
cli.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, register_global_subscription_argument) | ||
cli.register_event(events.EVENT_INVOKER_POST_CMD_TBL_CREATE, register_ids_argument) | ||
cli.raise_event(events.EVENT_INVOKER_CMD_TBL_LOADED, command_table=cmd_tbl) | ||
cli.invocation.parser.load_command_table(cli.invocation.commands_loader) | ||
_store_parsers(cli.invocation.parser, parser_dict) | ||
|
||
# TODO: do we want to update this as it doesn't actually load all help. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -196,6 +196,8 @@ def load_command_table(self, args): | |
@mock.patch('azure.cli.core.extension.get_extension_modname', _mock_extension_modname) | ||
@mock.patch('azure.cli.core.extension.get_extensions', _mock_get_extensions) | ||
def test_parser_error_spellchecker(self): | ||
import logging | ||
import azure | ||
cli = DummyCli() | ||
main_loader = MainCommandsLoader(cli) | ||
cli.loader = main_loader | ||
|
@@ -224,8 +226,8 @@ def mock_add_extension(*args, **kwargs): | |
pass | ||
|
||
# run multiple faulty commands and save error logs, as well as close matches | ||
with mock.patch('logging.Logger.error', mock_log_error), \ | ||
mock.patch('difflib.get_close_matches', mock_get_close_matches): | ||
with mock.patch.object(logging.Logger, 'error', mock_log_error), \ | ||
mock.patch.object(difflib, 'get_close_matches', mock_get_close_matches): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix this error which is also caused by https://github.com/Azure/azure-cli/pull/26923/files#r1271877325
|
||
faulty_cmd_args = [ | ||
'test module1 --opt enum_1', | ||
'test extension1 --opt enum_1', | ||
|
@@ -256,11 +258,14 @@ def mock_add_extension(*args, **kwargs): | |
self.assertIn(choice, choices) | ||
|
||
# test dynamic extension install | ||
with mock.patch('logging.Logger.error', mock_log_error), \ | ||
mock.patch('azure.cli.core.extension.operations.add_extension', mock_add_extension), \ | ||
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_command_tree', mock_ext_cmd_tree_load), \ | ||
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_use_dynamic_install_config', return_value='yes_without_prompt'), \ | ||
mock.patch('azure.cli.core.extension.dynamic_install._get_extension_run_after_dynamic_install_config', return_value=False): | ||
with mock.patch.object(logging.Logger, 'error', mock_log_error), \ | ||
mock.patch.object(azure.cli.core.extension.operations, 'add_extension', mock_add_extension), \ | ||
mock.patch.object(azure.cli.core.extension.dynamic_install, '_get_extension_command_tree', | ||
mock_ext_cmd_tree_load), \ | ||
mock.patch.object(azure.cli.core.extension.dynamic_install, '_get_extension_use_dynamic_install_config', | ||
return_value='yes_without_prompt'), \ | ||
mock.patch.object(azure.cli.core.extension.dynamic_install, | ||
'_get_extension_run_after_dynamic_install_config', return_value=False): | ||
with self.assertRaises(SystemExit): | ||
parser.parse_args('test new-ext create --opt enum_2'.split()) | ||
self.assertIn("Extension new-ext-name installed. Please rerun your command.", logger_msgs[5]) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should drop Python 3.10 tests right away as the bundled Python is still 3.10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bundled Python is also bumped in #26749