Skip to content

Commit 276e844

Browse files
committed
Use multiple choices to make output more obvious
1 parent 7c6096e commit 276e844

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
@@ -1937,23 +1937,25 @@ def test_required_subparsers_default(self):
19371937
def test_required_subparsers_no_destination_error(self):
19381938
parser = ErrorRaisingArgumentParser()
19391939
subparsers = parser.add_subparsers()
1940-
subparsers.add_parser('run')
1940+
subparsers.add_parser('foo')
1941+
subparsers.add_parser('bar')
19411942
with self.assertRaises(ArgumentParserError) as excinfo:
19421943
parser.parse_args(())
19431944
self.assertRegex(
19441945
excinfo.exception.stderr,
1945-
'error: the following arguments are required: {run}\n$'
1946+
'error: the following arguments are required: {foo,bar}\n$'
19461947
)
19471948

19481949
def test_wrong_argument_subparsers_no_destination_error(self):
19491950
parser = ErrorRaisingArgumentParser()
19501951
subparsers = parser.add_subparsers()
19511952
subparsers.add_parser('foo')
1953+
subparsers.add_parser('bar')
19521954
with self.assertRaises(ArgumentParserError) as excinfo:
1953-
parser.parse_args(('bar',))
1955+
parser.parse_args(('baz',))
19541956
self.assertRegex(
19551957
excinfo.exception.stderr,
1956-
r"error: argument {foo}: invalid choice: 'bar' \(choose from 'foo'\)\n$"
1958+
r"error: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$"
19571959
)
19581960

19591961
def test_optional_subparsers(self):

0 commit comments

Comments
 (0)