summaryrefslogtreecommitdiff
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-01-20 15:13:17 -0800
committerGitHub <noreply@github.com>2022-01-20 15:13:17 -0800
commite5edc8d737a45d9d8b9b93b8be52f85d79d0f417 (patch)
tree8448950dc9ab2057fdd805e4f821d9ea09104030 /Lib/test/test_argparse.py
parent876ade1ae3a805b546a211fd7303253c10395569 (diff)
downloadcpython-git-e5edc8d737a45d9d8b9b93b8be52f85d79d0f417.tar.gz
bpo-46080: fix argparse help generation exception in edge case (GH-30111)
Fix an uncaught exception during help text generation when argparse.BooleanOptionalAction is used with default=argparse.SUPPRESS and help is specified. (cherry picked from commit 9e87c0e03fa501fb90008547983ce4c1dcaaf90c) Co-authored-by: Felix Fontein <felix@fontein.de>
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 37a73e0686..9d66ace547 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -3597,6 +3597,8 @@ class TestHelpUsage(HelpTestCase):
Sig('--bar', help='Whether to bar', default=True,
action=argparse.BooleanOptionalAction),
Sig('-f', '--foobar', '--barfoo', action=argparse.BooleanOptionalAction),
+ Sig('--bazz', action=argparse.BooleanOptionalAction,
+ default=argparse.SUPPRESS, help='Bazz!'),
]
argument_group_signatures = [
(Sig('group'), [
@@ -3609,8 +3611,8 @@ class TestHelpUsage(HelpTestCase):
usage = '''\
usage: PROG [-h] [-w W [W ...]] [-x [X ...]] [--foo | --no-foo]
[--bar | --no-bar]
- [-f | --foobar | --no-foobar | --barfoo | --no-barfoo] [-y [Y]]
- [-z Z Z Z]
+ [-f | --foobar | --no-foobar | --barfoo | --no-barfoo]
+ [--bazz | --no-bazz] [-y [Y]] [-z Z Z Z]
a b b [c] [d ...] e [e ...]
'''
help = usage + '''\
@@ -3627,6 +3629,7 @@ class TestHelpUsage(HelpTestCase):
--foo, --no-foo Whether to foo
--bar, --no-bar Whether to bar (default: True)
-f, --foobar, --no-foobar, --barfoo, --no-barfoo
+ --bazz, --no-bazz Bazz!
group:
-y [Y] y