diff options
| author | Steven Bethard <steven.bethard@gmail.com> | 2011-03-26 13:48:04 (GMT) | 
|---|---|---|
| committer | Steven Bethard <steven.bethard@gmail.com> | 2011-03-26 13:48:04 (GMT) | 
| commit | 0331e906d6a3e52b2679284cebd71a2513a00bfe (patch) | |
| tree | cc12c86a098e597ae15868245d6f3165b462f81f /Lib/test/test_argparse.py | |
| parent | 657bd0a25ddac6a951baaa9ac3167d8bce1b7308 (diff) | |
| download | cpython-0331e906d6a3e52b2679284cebd71a2513a00bfe.zip cpython-0331e906d6a3e52b2679284cebd71a2513a00bfe.tar.gz cpython-0331e906d6a3e52b2679284cebd71a2513a00bfe.tar.bz2  | |
Issue #11174: Add argparse.MetavarTypeHelpFormatter, which uses type names
for the names of optional and positional arguments in help messages.
Diffstat (limited to 'Lib/test/test_argparse.py')
| -rw-r--r-- | Lib/test/test_argparse.py | 31 | 
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py index 8d80336..5a380cb 100644 --- a/Lib/test/test_argparse.py +++ b/Lib/test/test_argparse.py @@ -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  # =====================================  | 
