Skip to content

Commit 6a09976

Browse files
committed
Use multiple choices to make output more obvious
1 parent fd1a8c0 commit 6a09976

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Lib/test/test_argparse.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,23 +2063,25 @@ def test_required_subparsers_default(self):
20632063
def test_required_subparsers_no_destination_error(self):
20642064
parser = ErrorRaisingArgumentParser()
20652065
subparsers = parser.add_subparsers()
2066-
subparsers.add_parser('run')
2066+
subparsers.add_parser('foo')
2067+
subparsers.add_parser('bar')
20672068
with self.assertRaises(ArgumentParserError) as excinfo:
20682069
parser.parse_args(())
20692070
self.assertRegex(
20702071
excinfo.exception.stderr,
2071-
'error: the following arguments are required: {run}\n$'
2072+
'error: the following arguments are required: {foo,bar}\n$'
20722073
)
20732074

20742075
def test_wrong_argument_subparsers_no_destination_error(self):
20752076
parser = ErrorRaisingArgumentParser()
20762077
subparsers = parser.add_subparsers()
20772078
subparsers.add_parser('foo')
2079+
subparsers.add_parser('bar')
20782080
with self.assertRaises(ArgumentParserError) as excinfo:
2079-
parser.parse_args(('bar',))
2081+
parser.parse_args(('baz',))
20802082
self.assertRegex(
20812083
excinfo.exception.stderr,
2082-
r"error: argument {foo}: invalid choice: 'bar' \(choose from 'foo'\)\n$"
2084+
r"error: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$"
20832085
)
20842086

20852087
def test_optional_subparsers(self):

0 commit comments

Comments
 (0)