summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsteven.bethard <devnull@localhost>2009-07-26 14:59:44 +0000
committersteven.bethard <devnull@localhost>2009-07-26 14:59:44 +0000
commit25d79f58974cc14f475a4762926981e247c9f70c (patch)
tree92214fd0ee60b4cb7d35ca84f34450952fc4d8f0 /test
parent8a09594f57b03fa145267e17761940257554ab29 (diff)
downloadargparse-25d79f58974cc14f475a4762926981e247c9f70c.tar.gz
Allow subparsers to take title= and description= parameters.
Diffstat (limited to 'test')
-rw-r--r--test/test_argparse.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/test_argparse.py b/test/test_argparse.py
index bd5a854..011b9b6 100644
--- a/test/test_argparse.py
+++ b/test/test_argparse.py
@@ -1654,6 +1654,36 @@ class TestAddSubparsers(TestCase):
--foo foo help
'''))
+ def test_subparser_title_help(self):
+ parser = ErrorRaisingArgumentParser(prog='PROG',
+ description='main description')
+ parser.add_argument('--foo', action='store_true', help='foo help')
+ parser.add_argument('bar', help='bar help')
+ subparsers = parser.add_subparsers(title='subcommands',
+ description='command help',
+ help='additional text')
+ parser1 = subparsers.add_parser('1')
+ parser2 = subparsers.add_parser('2')
+ self.assertEqual(parser.format_usage(),
+ 'usage: PROG [-h] [--foo] bar {1,2} ...\n')
+ self.assertEqual(parser.format_help(), textwrap.dedent('''\
+ usage: PROG [-h] [--foo] bar {1,2} ...
+
+ main description
+
+ positional arguments:
+ bar bar help
+
+ optional arguments:
+ -h, --help show this help message and exit
+ --foo foo help
+
+ subcommands:
+ command help
+
+ {1,2} additional text
+ '''))
+
def _test_subparser_help(self, args_str, expected_help):
try:
self.parser.parse_args(args_str.split())