From 8c58bb558adceb8ff32c7a3e1a88d2a13371dbfa Mon Sep 17 00:00:00 2001 From: kotfu Date: Sun, 7 Jan 2018 18:30:34 -0700 Subject: Properly set docstring so it contains help message --- tests/test_argparse.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'tests/test_argparse.py') diff --git a/tests/test_argparse.py b/tests/test_argparse.py index 9b49267e..41173c8b 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -15,7 +15,6 @@ class ArgparseApp(cmd2.Cmd): argparser = argparse.ArgumentParser( prog='say', - description='Repeats what you tell me to' ) argparser.add_argument('-p', '--piglatin', action='store_true', help='atinLay') argparser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE') @@ -23,6 +22,7 @@ class ArgparseApp(cmd2.Cmd): argparser.add_argument('words', nargs='+', help='words to say') @cmd2.with_argument_parser(argparser) def do_say(self, cmdline, args=None): + """Repeat what you tell me to.""" words = [] for word in args.words: if word is None: @@ -39,7 +39,7 @@ class ArgparseApp(cmd2.Cmd): argparser = argparse.ArgumentParser( prog='tag', - description='create an html tag, the first argument is the tag, the rest is the contents' + description='create a html tag' ) argparser.add_argument('tag', nargs=1, help='tag') argparser.add_argument('content', nargs='+', help='content to surround with tag') @@ -80,3 +80,11 @@ def test_argparse_quoted_arguments_posix_multiple(argparse_app): argparse_app.POSIX = True out = run_cmd(argparse_app, 'tag strong this "should be" loud') assert out == ['this should be loud'] + +def test_argparse_help_docstring(argparse_app): + out = run_cmd(argparse_app, 'help say') + assert out[0] == 'Repeat what you tell me to.' + +def test_argparse_help_description(argparse_app): + out = run_cmd(argparse_app, 'help tag') + assert out[2] == 'create a html tag' -- cgit v1.2.1