mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (GH-102318)
(cherry picked from commit 9a478be1a4
)
Co-authored-by: Yeojin Kim <yeojin.dev@gmail.com>
This commit is contained in:
parent
63fd954100
commit
e748f9e270
3 changed files with 34 additions and 3 deletions
|
@ -3753,6 +3753,28 @@ class TestHelpUsage(HelpTestCase):
|
|||
version = ''
|
||||
|
||||
|
||||
class TestHelpUsageWithParentheses(HelpTestCase):
|
||||
parser_signature = Sig(prog='PROG')
|
||||
argument_signatures = [
|
||||
Sig('positional', metavar='(example) positional'),
|
||||
Sig('-p', '--optional', metavar='{1 (option A), 2 (option B)}'),
|
||||
]
|
||||
|
||||
usage = '''\
|
||||
usage: PROG [-h] [-p {1 (option A), 2 (option B)}] (example) positional
|
||||
'''
|
||||
help = usage + '''\
|
||||
|
||||
positional arguments:
|
||||
(example) positional
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
-p {1 (option A), 2 (option B)}, --optional {1 (option A), 2 (option B)}
|
||||
'''
|
||||
version = ''
|
||||
|
||||
|
||||
class TestHelpOnlyUserGroups(HelpTestCase):
|
||||
"""Test basic usage messages"""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue