Issue #11174: Add argparse.MetavarTypeHelpFormatter, which uses type names

for the names of optional and positional arguments in help messages.
This commit is contained in:
Steven Bethard 2011-03-26 14:48:04 +01:00
parent 657bd0a25d
commit 0331e906d6
4 changed files with 89 additions and 14 deletions

View file

@ -3940,6 +3940,37 @@ class TestHelpVersionAction(HelpTestCase):
'''
version = ''
class TestHelpMetavarTypeFormatter(HelpTestCase):
""""""
def custom_type(string):
return string
parser_signature = Sig(prog='PROG', description='description',
formatter_class=argparse.MetavarTypeHelpFormatter)
argument_signatures = [Sig('a', type=int),
Sig('-b', type=custom_type),
Sig('-c', type=float, metavar='SOME FLOAT')]
argument_group_signatures = []
usage = '''\
usage: PROG [-h] [-b custom_type] [-c SOME FLOAT] int
'''
help = usage + '''\
description
positional arguments:
int
optional arguments:
-h, --help show this help message and exit
-b custom_type
-c SOME FLOAT
'''
version = ''
# =====================================
# Optional/Positional constructor tests
# =====================================