summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-01-07 20:02:38 -0700
committerkotfu <kotfu@kotfu.net>2018-01-07 20:02:38 -0700
commit6cb43c600f0b5d694201233ade6abd4f989d1730 (patch)
treec9acbeaf507a762db0b05b32a1e824b479279bfe /tests
parent8c58bb558adceb8ff32c7a3e1a88d2a13371dbfa (diff)
downloadcmd2-git-6cb43c600f0b5d694201233ade6abd4f989d1730.tar.gz
Set prog in argparser based on the name of the function
Diffstat (limited to 'tests')
-rw-r--r--tests/test_argparse.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py
index 41173c8b..e9dbc1b3 100644
--- a/tests/test_argparse.py
+++ b/tests/test_argparse.py
@@ -13,9 +13,7 @@ class ArgparseApp(cmd2.Cmd):
self.maxrepeats = 3
cmd2.Cmd.__init__(self)
- argparser = argparse.ArgumentParser(
- prog='say',
- )
+ argparser = argparse.ArgumentParser()
argparser.add_argument('-p', '--piglatin', action='store_true', help='atinLay')
argparser.add_argument('-s', '--shout', action='store_true', help='N00B EMULATION MODE')
argparser.add_argument('-r', '--repeat', type=int, help='output [n] times')
@@ -37,10 +35,7 @@ class ArgparseApp(cmd2.Cmd):
self.stdout.write(' '.join(words))
self.stdout.write('\n')
- argparser = argparse.ArgumentParser(
- prog='tag',
- description='create a html tag'
- )
+ argparser = argparse.ArgumentParser(description='create a html tag')
argparser.add_argument('tag', nargs=1, help='tag')
argparser.add_argument('content', nargs='+', help='content to surround with tag')
@cmd2.with_argument_parser(argparser)
@@ -88,3 +83,9 @@ def test_argparse_help_docstring(argparse_app):
def test_argparse_help_description(argparse_app):
out = run_cmd(argparse_app, 'help tag')
assert out[2] == 'create a html tag'
+
+def test_argparse_prog(argparse_app):
+ out = run_cmd(argparse_app, 'help tag')
+ progname = out[0].split(' ')[1]
+ assert progname == 'tag'
+ \ No newline at end of file