summaryrefslogtreecommitdiff
path: root/tests/test_argparse.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-15 13:36:29 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-15 13:36:29 -0500
commit38989c8d406020d300801331f86255865f133561 (patch)
treeb41a905adadeb2a5b127d972ef88fd1ff1a02616 /tests/test_argparse.py
parentda0a44888312eefba3f6d8c07efd784875691129 (diff)
downloadcmd2-git-38989c8d406020d300801331f86255865f133561.tar.gz
Added a unit test
Diffstat (limited to 'tests/test_argparse.py')
-rw-r--r--tests/test_argparse.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py
index b425d63c..fea9bebb 100644
--- a/tests/test_argparse.py
+++ b/tests/test_argparse.py
@@ -81,6 +81,22 @@ class ArgparseApp(cmd2.Cmd):
self.stdout.write(' '.join(words))
self.stdout.write('\n')
+ @cmd2.with_argparser_and_unknown_args(known_parser)
+ def do_talk(self, args, extra):
+ words = []
+ for word in extra:
+ if word is None:
+ word = ''
+ if args.piglatin:
+ word = '%s%say' % (word[1:], word[0])
+ if args.shout:
+ word = word.upper()
+ words.append(word)
+ repetitions = args.repeat or 1
+ for i in range(min(repetitions, self.maxrepeats)):
+ self.stdout.write(' '.join(words))
+ self.stdout.write('\n')
+
@pytest.fixture
def argparse_app():
app = ArgparseApp()
@@ -102,6 +118,10 @@ def test_argparse_with_list(argparse_app):
out = run_cmd(argparse_app, 'speak -s hello world!')
assert out == ['HELLO WORLD!']
+def test_argparse_with_list_and_empty_doc(argparse_app):
+ out = run_cmd(argparse_app, 'speak -s hello world!')
+ assert out == ['HELLO WORLD!']
+
def test_argparse_quoted_arguments_multiple(argparse_app):
argparse_app.POSIX = False
argparse_app.STRIP_QUOTES_FOR_NON_POSIX = True