summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-04-10 13:11:12 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-04-10 13:11:12 (GMT)
commitecb75e26db7545b05b7eee10c5e0ff0801a52794 (patch)
treeaa3dfdad2e1e8a8598f8cf9cd6a9b54d4a955acb
parent7e7a3dba5fd4262269f713dfe21ba7e4746fc2dd (diff)
downloadcpython-ecb75e26db7545b05b7eee10c5e0ff0801a52794.zip
cpython-ecb75e26db7545b05b7eee10c5e0ff0801a52794.tar.gz
cpython-ecb75e26db7545b05b7eee10c5e0ff0801a52794.tar.bz2
Issue #23062: Add a test for suppressing --version with argparse.SUPPRESS.
TestHelpVersionOptional was redundant.
-rw-r--r--Lib/test/test_argparse.py54
1 files changed, 26 insertions, 28 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 1164f3f..ecc5507 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -3845,34 +3845,6 @@ class TestHelpNoHelpOptional(HelpTestCase):
version = ''
-class TestHelpVersionOptional(HelpTestCase):
- """Test that the --version argument can be suppressed help messages"""
-
- parser_signature = Sig(prog='PROG')
- argument_signatures = [
- Sig('-v', '--version', action='version', version='1.0'),
- Sig('--foo', help='foo help'),
- Sig('spam', help='spam help'),
- ]
- argument_group_signatures = []
- usage = '''\
- usage: PROG [-h] [-v] [--foo FOO] spam
- '''
- help = usage + '''\
-
- positional arguments:
- spam spam help
-
- optional arguments:
- -h, --help show this help message and exit
- -v, --version show program's version number and exit
- --foo FOO foo help
- '''
- version = '''\
- 1.0
- '''
-
-
class TestHelpNone(HelpTestCase):
"""Test that no errors occur if no help is specified"""
@@ -4080,6 +4052,32 @@ class TestHelpVersionAction(HelpTestCase):
'''
version = ''
+
+class TestHelpVersionActionSuppress(HelpTestCase):
+ """Test that the --version argument can be suppressed in help messages"""
+
+ parser_signature = Sig(prog='PROG')
+ argument_signatures = [
+ Sig('-v', '--version', action='version', version='1.0',
+ help=argparse.SUPPRESS),
+ Sig('--foo', help='foo help'),
+ Sig('spam', help='spam help'),
+ ]
+ argument_group_signatures = []
+ usage = '''\
+ usage: PROG [-h] [--foo FOO] spam
+ '''
+ help = usage + '''\
+
+ positional arguments:
+ spam spam help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo FOO foo help
+ '''
+
+
class TestHelpSubparsersOrdering(HelpTestCase):
"""Test ordering of subcommands in help matches the code"""
parser_signature = Sig(prog='PROG',