diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2015-04-10 13:11:45 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2015-04-10 13:11:45 (GMT) |
commit | 82c920c59e3345af32c726ae0ce7aa9073a81c33 (patch) | |
tree | 3e37525ee9219f98e9fc7ed3ea817f8a43c5800d | |
parent | 2116b12da59f77358cc539b90f58a3cdea43c2fd (diff) | |
parent | ecb75e26db7545b05b7eee10c5e0ff0801a52794 (diff) | |
download | cpython-82c920c59e3345af32c726ae0ce7aa9073a81c33.zip cpython-82c920c59e3345af32c726ae0ce7aa9073a81c33.tar.gz cpython-82c920c59e3345af32c726ae0ce7aa9073a81c33.tar.bz2 |
Issue #23062: Add a test for suppressing --version with argparse.SUPPRESS.
TestHelpVersionOptional was redundant.
-rw-r--r-- | Lib/test/test_argparse.py | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index d7f90cd..27bfad5 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -3852,34 +3852,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""" @@ -4087,6 +4059,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', |