diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-03-05 07:16:14 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 07:16:14 -0800 |
commit | 2a062f275970b3775b055c2c82f31b766271ae18 (patch) | |
tree | b979dcc7adbe32657e2a6b90c376869eaaf03719 /Lib/test/test_argparse.py | |
parent | d4a04e55d8bd8eaa307f3e4aa8b443301a0d996a (diff) | |
download | cpython-git-2a062f275970b3775b055c2c82f31b766271ae18.tar.gz |
gh-101979: argparse: fix a bug where parentheses in metavar argument of add_argument() were dropped (GH-102318)
(cherry picked from commit 9a478be1a4314734c697dda7a7b0e633a6fb0751)
Co-authored-by: Yeojin Kim <yeojin.dev@gmail.com>
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r-- | Lib/test/test_argparse.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 4d43e3310d..5df6f32630 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3729,6 +3729,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""" |