Skip to content

Commit 6eeae5c

Browse files
committed
test cases fixed 🔨
1 parent 087895c commit 6eeae5c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ def _check_value(self, action, value):
25482548
args = {'value': value,
25492549
'choices': ', '.join(map(repr, action.choices))}
25502550

2551-
if closest_choice := closest_choice and closest_choice[0] or '':
2551+
if closest_choice := closest_choice and closest_choice[0] or '':
25522552
args['closest'] = closest_choice
25532553
msg = _('invalid choice: %(value)r, maybe you meant %(closest)r? '
25542554
'(choose from %(choices)s)')

Lib/test/test_argparse.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,12 +2192,10 @@ def test_wrong_argument_subparsers_no_destination_error(self):
21922192
subparsers.add_parser('foo')
21932193
subparsers.add_parser('bar')
21942194
with self.assertRaises(ArgumentParserError) as excinfo:
2195-
parser.parse_args(('baz',))
2196-
self.assertEqual(
2195+
parser.parse_args(('python',))
2196+
self.assertRegex(
21972197
excinfo.exception.stderr,
2198-
"usage: __main__.py [-h] {foo,bar} ...\\n__main__.py: error: argument"
2199-
" {foo,bar}: invalid choice: 'baz', maybe you meant 'bar'?"
2200-
" (choose from 'foo', 'bar')\\n"
2198+
r"error: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$"
22012199
)
22022200

22032201
def test_optional_subparsers(self):

0 commit comments

Comments
 (0)