azure-cli-core: Test failures with conflicting subparsers in Python 3.11.0b3
See original GitHub issueRelated command
Attempting to run tests for azure-cli-core
.
Describe the bug
While running pytest
to test azure-cli-core
, many tests fail in Python 3.11.0b3 due to conflicting subparsers. Here is an example:
__________________ TestParser.test_parser_error_spellchecker ___________________
[gw0] linux -- Python 3.11.0 /usr/bin/python3
self = <azure.cli.core.tests.test_parser.TestParser testMethod=test_parser_error_spellchecker>
@mock.patch('importlib.import_module', _mock_import_lib)
@mock.patch('pkgutil.iter_modules', _mock_iter_modules)
@mock.patch('azure.cli.core.commands._load_command_loader', _mock_load_command_loader)
@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):
cli = DummyCli()
main_loader = MainCommandsLoader(cli)
cli.loader = main_loader
cli.loader.load_command_table(None)
parser = cli.parser_cls(cli)
> parser.load_command_table(cli.loader)
src/azure-cli-core/azure/cli/core/tests/test_parser.py:206:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/azure-cli-core/azure/cli/core/parser.py:100: in load_command_table
command_parser = subparser.add_parser(command_verb,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = _SubParsersAction(option_strings=[], dest='_subcommand', nargs='A...', const=None, default=None, type=None, choices={'module': 'module'}, required=True, help=None, metavar=None)
name = 'module'
kwargs = {'_command_source': 'azure.cli.core.tests.test_parser', 'cli_help': None, 'conflict_handler': 'error', 'description': None, ...}
aliases = ()
def add_parser(self, name, **kwargs):
# set prog from the existing prefix
if kwargs.get('prog') is None:
kwargs['prog'] = '%s %s' % (self._prog_prefix, name)
aliases = kwargs.pop('aliases', ())
if name in self._name_parser_map:
> raise ArgumentError(self, _('conflicting subparser: %s') % name)
E argparse.ArgumentError: argument _subcommand: conflicting subparser: module
/usr/lib64/python3.11/argparse.py:1185: ArgumentError
For the full output, check the build log from a Fedora package build. I’ve also copied out just the pytest output into a GitHub Gist to make it easier to read.
To Reproduce
Run pytest src/azure-cli-core
with Python 3.11.0b3.
Expected behavior I expected the tests to pass (as they do in Python 3.10.5).
Environment summary
Building an RPM package for azure-cli
with Python 3.11.0b3 in Fedora 37.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Python Release Python 3.11.0b3
Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their...
Read more >Python Release Python 3.11.0b1
Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their...
Read more >Python Release Python 3.11.1
Python 3.11.1 is the newest major release of the Python programming language, and it contains many new features and optimizations.
Read more >Python Release Python 3.11.0b5
Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their...
Read more >Python Release Python 3.11.0b4
Beta release previews are intended to give the wider community the opportunity to test new features and bug fixes and to prepare their...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(Greetings – on the team working on Python 3.11 👋)
This seems to do the trick for me. The workaround for that bug no longer seems to be required.
EDIT: lmk if you’d like a PR.
Python 3.11 is out, can you please merge https://github.com/Azure/azure-cli/pull/24109?