mirror of
https://github.com/python/cpython.git
synced 2025-07-25 04:04:13 +00:00
[3.13] gh-125254: Fix error report about ambiguous option in argparse (GH-125273) (GH-125359)
This was a regression introduced in gh-58573. It was only tested for the
case when the ambiguous option is the last argument in the command line.
(cherry picked from commit 63cf4e914f
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
b4c504d76f
commit
33c41360c8
3 changed files with 14 additions and 3 deletions
|
@ -6680,9 +6680,19 @@ class TestExitOnError(TestCase):
|
|||
def test_ambiguous_option(self):
|
||||
self.parser.add_argument('--foobaz')
|
||||
self.parser.add_argument('--fooble', action='store_true')
|
||||
self.parser.add_argument('--foogle')
|
||||
self.assertRaisesRegex(argparse.ArgumentError,
|
||||
"ambiguous option: --foob could match --foobaz, --fooble",
|
||||
self.parser.parse_args, ['--foob'])
|
||||
"ambiguous option: --foob could match --foobaz, --fooble",
|
||||
self.parser.parse_args, ['--foob'])
|
||||
self.assertRaisesRegex(argparse.ArgumentError,
|
||||
"ambiguous option: --foob=1 could match --foobaz, --fooble$",
|
||||
self.parser.parse_args, ['--foob=1'])
|
||||
self.assertRaisesRegex(argparse.ArgumentError,
|
||||
"ambiguous option: --foob could match --foobaz, --fooble$",
|
||||
self.parser.parse_args, ['--foob', '1', '--foogle', '2'])
|
||||
self.assertRaisesRegex(argparse.ArgumentError,
|
||||
"ambiguous option: --foob=1 could match --foobaz, --fooble$",
|
||||
self.parser.parse_args, ['--foob=1', '--foogle', '2'])
|
||||
|
||||
def test_os_error(self):
|
||||
self.parser.add_argument('file')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue