Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ecb75e2

Browse files
committed
Issue #23062: Add a test for suppressing --version with argparse.SUPPRESS.
TestHelpVersionOptional was redundant.
1 parent 7e7a3db commit ecb75e2

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

Lib/test/test_argparse.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3845,34 +3845,6 @@ class TestHelpNoHelpOptional(HelpTestCase):
38453845
version = ''
38463846

38473847

3848-
class TestHelpVersionOptional(HelpTestCase):
3849-
"""Test that the --version argument can be suppressed help messages"""
3850-
3851-
parser_signature = Sig(prog='PROG')
3852-
argument_signatures = [
3853-
Sig('-v', '--version', action='version', version='1.0'),
3854-
Sig('--foo', help='foo help'),
3855-
Sig('spam', help='spam help'),
3856-
]
3857-
argument_group_signatures = []
3858-
usage = '''\
3859-
usage: PROG [-h] [-v] [--foo FOO] spam
3860-
'''
3861-
help = usage + '''\
3862-
3863-
positional arguments:
3864-
spam spam help
3865-
3866-
optional arguments:
3867-
-h, --help show this help message and exit
3868-
-v, --version show program's version number and exit
3869-
--foo FOO foo help
3870-
'''
3871-
version = '''\
3872-
1.0
3873-
'''
3874-
3875-
38763848
class TestHelpNone(HelpTestCase):
38773849
"""Test that no errors occur if no help is specified"""
38783850

@@ -4080,6 +4052,32 @@ class TestHelpVersionAction(HelpTestCase):
40804052
'''
40814053
version = ''
40824054

4055+
4056+
class TestHelpVersionActionSuppress(HelpTestCase):
4057+
"""Test that the --version argument can be suppressed in help messages"""
4058+
4059+
parser_signature = Sig(prog='PROG')
4060+
argument_signatures = [
4061+
Sig('-v', '--version', action='version', version='1.0',
4062+
help=argparse.SUPPRESS),
4063+
Sig('--foo', help='foo help'),
4064+
Sig('spam', help='spam help'),
4065+
]
4066+
argument_group_signatures = []
4067+
usage = '''\
4068+
usage: PROG [-h] [--foo FOO] spam
4069+
'''
4070+
help = usage + '''\
4071+
4072+
positional arguments:
4073+
spam spam help
4074+
4075+
optional arguments:
4076+
-h, --help show this help message and exit
4077+
--foo FOO foo help
4078+
'''
4079+
4080+
40834081
class TestHelpSubparsersOrdering(HelpTestCase):
40844082
"""Test ordering of subcommands in help matches the code"""
40854083
parser_signature = Sig(prog='PROG',

0 commit comments

Comments
 (0)