summaryrefslogtreecommitdiff
path: root/tests/test_argparse.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-04 20:40:28 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2019-03-04 20:40:28 -0500
commit28e44aac56ea21be8aa3bea5d93325d0edd836be (patch)
tree434e64307f030ed5a62c062943c694b782ef85f9 /tests/test_argparse.py
parentde701086ff832bad0f0d97ffb10c2159d56ede7d (diff)
downloadcmd2-git-28e44aac56ea21be8aa3bea5d93325d0edd836be.tar.gz
Fix for when with_argument_list is called with preserve_quotes optional argument
Diffstat (limited to 'tests/test_argparse.py')
-rw-r--r--tests/test_argparse.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py
index 7db35c71..a055ac72 100644
--- a/tests/test_argparse.py
+++ b/tests/test_argparse.py
@@ -68,6 +68,10 @@ class ArgparseApp(cmd2.Cmd):
else:
self.stdout.write('False')
+ @cmd2.with_argument_list(preserve_quotes=True)
+ def do_preservelist(self, arglist):
+ self.stdout.write('{}'.format(arglist))
+
@cmd2.with_argument_list
@cmd2.with_argument_list
def do_arglisttwice(self, arglist):
@@ -174,6 +178,10 @@ def test_arglist(argparse_app):
out = run_cmd(argparse_app, 'arglist "we should" get these')
assert out[0] == 'True'
+def test_preservelist(argparse_app):
+ out = run_cmd(argparse_app, 'preservelist foo "bar baz"')
+ assert out[0] == "['foo', '\"bar baz\"']"
+
def test_arglist_decorator_twice(argparse_app):
out = run_cmd(argparse_app, 'arglisttwice "we should" get these')
assert out[0] == 'we should get these'