Skip to content

Commit a11d740

Browse files
author
Fabian Henze
committed
gh-112527: Add unit test
1 parent 9032f73 commit a11d740

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ def _get_help_string(self, action):
747747
and action.default is not SUPPRESS
748748
and not action.required
749749
):
750-
defaulting_nargs = [OPTIONAL, ZERO_OR_MORE]
750+
defaulting_nargs = (OPTIONAL, ZERO_OR_MORE)
751751
if action.option_strings or action.nargs in defaulting_nargs:
752752
t = self._theme
753753
default_str = _(" (default: %(default)s)")

Lib/test/test_argparse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,6 +5381,7 @@ class TestHelpArgumentDefaults(HelpTestCase):
53815381
argument_signatures = [
53825382
Sig('--foo', help='foo help - oh and by the way, %(default)s'),
53835383
Sig('--bar', action='store_true', help='bar help'),
5384+
Sig('--required', required=True, help='some help'),
53845385
Sig('--taz', action=argparse.BooleanOptionalAction,
53855386
help='Whether to taz it', default=True),
53865387
Sig('--corge', action=argparse.BooleanOptionalAction,
@@ -5394,8 +5395,8 @@ class TestHelpArgumentDefaults(HelpTestCase):
53945395
[Sig('--baz', type=int, default=42, help='baz help')]),
53955396
]
53965397
usage = '''\
5397-
usage: PROG [-h] [--foo FOO] [--bar] [--taz | --no-taz] [--corge | --no-corge]
5398-
[--quux QUUX] [--baz BAZ]
5398+
usage: PROG [-h] [--foo FOO] [--bar] --required REQUIRED [--taz | --no-taz]
5399+
[--corge | --no-corge] [--quux QUUX] [--baz BAZ]
53995400
spam [badger]
54005401
'''
54015402
help = usage + '''\
@@ -5410,6 +5411,7 @@ class TestHelpArgumentDefaults(HelpTestCase):
54105411
-h, --help show this help message and exit
54115412
--foo FOO foo help - oh and by the way, None
54125413
--bar bar help (default: False)
5414+
--required REQUIRED some help
54135415
--taz, --no-taz Whether to taz it (default: True)
54145416
--corge, --no-corge Whether to corge it
54155417
--quux QUUX Set the quux (default: 42)

0 commit comments

Comments
 (0)