diff options
| author | kotfu <kotfu@kotfu.net> | 2018-01-12 23:11:53 -0700 |
|---|---|---|
| committer | kotfu <kotfu@kotfu.net> | 2018-01-12 23:11:53 -0700 |
| commit | 405f4e4e951e0af46c7c5d746459f24e5c316eab (patch) | |
| tree | 7933766506292f7610d5b05aa5f6615b32e2bff7 /tests/test_argparse.py | |
| parent | c26b00853633c7df8cdee0ee49b3596154bb09c1 (diff) | |
| download | cmd2-git-405f4e4e951e0af46c7c5d746459f24e5c316eab.tar.gz | |
add use_argument_list setting
new attribute on Cmd2.cmd which defaults to false, but if set true, causes all do_* commands to receive a list of arguments, instead of a string of what the user typed.
Diffstat (limited to 'tests/test_argparse.py')
| -rw-r--r-- | tests/test_argparse.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_argparse.py b/tests/test_argparse.py index 308824cf..7d6d99de 100644 --- a/tests/test_argparse.py +++ b/tests/test_argparse.py @@ -71,12 +71,29 @@ class ArgparseApp(cmd2.Cmd): else: self.stdout.write('False') +class ArglistApp(cmd2.Cmd): + def __init__(self): + self.use_argument_list = True + cmd2.Cmd.__init__(self) + + def do_arglist(self, arglist): + if isinstance(arglist, list): + self.stdout.write('True') + else: + self.stdout.write('False') + @pytest.fixture def argparse_app(): app = ArgparseApp() app.stdout = StdOut() return app +@pytest.fixture +def arglist_app(): + app = ArglistApp() + app.stdout = StdOut() + return app + def test_argparse_basic_command(argparse_app): out = run_cmd(argparse_app, 'say hello') assert out == ['hello'] @@ -127,3 +144,7 @@ def test_argparse_arglist(argparse_app): def test_arglist(argparse_app): out = run_cmd(argparse_app, 'arglist "we should" get these in a list, not a string') assert out[0] == 'True' + +def test_use_argument_list(arglist_app): + out = run_cmd(arglist_app, 'arglist "we should" get these in a list, not a string') + assert out[0] == 'True' |
