diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-01-20 10:08:13 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-20 10:08:13 -0500 |
commit | 7b564b4424accfbd7439de10a169d9b64bc599c5 (patch) | |
tree | e9d3b691b9900827f85e0b1e19f3d0355331fb9d /tests/test_argparse.py | |
parent | 91bc999d022a486334b9054859e2ef6f03ca9666 (diff) | |
parent | 03f15696076b04a2881562a0429a435e61ffd92c (diff) | |
download | cmd2-git-7b564b4424accfbd7439de10a169d9b64bc599c5.tar.gz |
Merge pull request #255 from python-cmd2/argparse_help
Improved how new argparse-based decorators provide help
Diffstat (limited to 'tests/test_argparse.py')
-rw-r--r-- | tests/test_argparse.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py index fea9bebb..21e81603 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -37,12 +37,12 @@ class ArgparseApp(cmd2.Cmd): self.stdout.write('\n') tag_parser = argparse.ArgumentParser(description='create a html tag') - tag_parser.add_argument('tag', nargs=1, help='tag') + tag_parser.add_argument('tag', help='tag') tag_parser.add_argument('content', nargs='+', help='content to surround with tag') @cmd2.with_argument_parser(tag_parser) def do_tag(self, args): - self.stdout.write('<{0}>{1}</{0}>'.format(args.tag[0], ' '.join(args.content))) + self.stdout.write('<{0}>{1}</{0}>'.format(args.tag, ' '.join(args.content))) self.stdout.write('\n') @cmd2.with_argument_list @@ -140,10 +140,14 @@ def test_argparse_quoted_arguments_posix_multiple(argparse_app): def test_argparse_help_docstring(argparse_app): out = run_cmd(argparse_app, 'help say') - assert out[0] == 'Repeat what you tell me to.' + assert out[0].startswith('usage: say') + assert out[1] == '' + assert out[2] == 'Repeat what you tell me to.' def test_argparse_help_description(argparse_app): out = run_cmd(argparse_app, 'help tag') + assert out[0].startswith('usage: tag') + assert out[1] == '' assert out[2] == 'create a html tag' def test_argparse_prog(argparse_app): |