mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
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:
parent
657bd0a25d
commit
0331e906d6
4 changed files with 89 additions and 14 deletions
|
@ -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
|
||||
# =====================================
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue