mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 10:44:36 +08:00
Update argparse.py to 3.14.5 (#7832)
This commit is contained in:
1 parent
ad6cc8f0a2
commit
9f019a5b86
2 files changed
+9
-9
No files matched your search
Vendored
+1
-1
@@ -2678,7 +2678,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||
|
||||
if value not in choices:
|
||||
args = {'value': str(value),
|
||||
'choices': ', '.join(map(str, action.choices))}
|
||||
'choices': ', '.join(repr(str(choice)) for choice in action.choices)}
|
||||
msg = _('invalid choice: %(value)r (choose from %(choices)s)')
|
||||
|
||||
if self.suggest_on_error and isinstance(value, str):
|
||||
|
||||
Vendored
+8
-8
@@ -1045,7 +1045,7 @@ class TestStrEnumChoices(TestCase):
|
||||
parser.add_argument('--color', choices=self.Color)
|
||||
self.assertRaisesRegex(
|
||||
argparse.ArgumentError,
|
||||
r"invalid choice: 'yellow' \(choose from red, green, blue\)",
|
||||
r"invalid choice: 'yellow' \(choose from 'red', 'green', 'blue'\)",
|
||||
parser.parse_args,
|
||||
['--color', 'yellow'],
|
||||
)
|
||||
@@ -2313,7 +2313,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('bazz',))
|
||||
self.assertIn(
|
||||
"error: argument foo: invalid choice: 'bazz', maybe you meant 'baz'? (choose from bar, baz)",
|
||||
"error: argument foo: invalid choice: 'bazz', maybe you meant 'baz'? (choose from 'bar', 'baz')",
|
||||
excinfo.exception.stderr
|
||||
)
|
||||
|
||||
@@ -2323,7 +2323,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('bazz',))
|
||||
self.assertIn(
|
||||
"error: argument foo: invalid choice: 'bazz' (choose from bar, baz)",
|
||||
"error: argument foo: invalid choice: 'bazz' (choose from 'bar', 'baz')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
@@ -2336,7 +2336,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
parser.parse_args(('baz',))
|
||||
self.assertIn(
|
||||
"error: argument {foo,bar}: invalid choice: 'baz', maybe you meant"
|
||||
" 'bar'? (choose from foo, bar)",
|
||||
" 'bar'? (choose from 'foo', 'bar')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
@@ -2348,7 +2348,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('baz',))
|
||||
self.assertIn(
|
||||
"error: argument {foo,bar}: invalid choice: 'baz' (choose from foo, bar)",
|
||||
"error: argument {foo,bar}: invalid choice: 'baz' (choose from 'foo', 'bar')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
@@ -2358,7 +2358,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('bazz',))
|
||||
self.assertIn(
|
||||
"error: argument foo: invalid choice: 'bazz' (choose from bar, baz)",
|
||||
"error: argument foo: invalid choice: 'bazz' (choose from 'bar', 'baz')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
@@ -2378,7 +2378,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('3',))
|
||||
self.assertIn(
|
||||
"error: argument foo: invalid choice: '3' (choose from 1, 2)",
|
||||
"error: argument foo: invalid choice: '3' (choose from '1', '2')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
@@ -2388,7 +2388,7 @@ class TestArgumentAndSubparserSuggestions(TestCase):
|
||||
with self.assertRaises(ArgumentParserError) as excinfo:
|
||||
parser.parse_args(('3',))
|
||||
self.assertIn(
|
||||
"error: argument foo: invalid choice: '3' (choose from 1, 2)",
|
||||
"error: argument foo: invalid choice: '3' (choose from '1', '2')",
|
||||
excinfo.exception.stderr,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user