diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-10-09 20:04:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-09 20:04:50 -0400 |
commit | f38e100fd77f4a136a4883d23b2f4f8b3cd934b7 (patch) | |
tree | c289c216807646567953191d35ebdc5c07198c24 /tests/test_pyscript.py | |
parent | 467be57e647112f536becc8625ffa080cb67a0ce (diff) | |
parent | 84f290bfdd82eb1c2eaf26b5936f7088b4911f2c (diff) | |
download | cmd2-git-f38e100fd77f4a136a4883d23b2f4f8b3cd934b7.tar.gz |
Merge pull request #571 from python-cmd2/argparse_remainder
Fixes related to handling of argparse.REMAINDER
Diffstat (limited to 'tests/test_pyscript.py')
-rw-r--r-- | tests/test_pyscript.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_pyscript.py b/tests/test_pyscript.py index 6b72e940..bcb72a3b 100644 --- a/tests/test_pyscript.py +++ b/tests/test_pyscript.py @@ -9,7 +9,7 @@ import os import pytest from cmd2.cmd2 import Cmd, with_argparser from cmd2 import argparse_completer -from .conftest import run_cmd +from .conftest import run_cmd, normalize from cmd2.utils import namedtuple_with_defaults, StdSim @@ -234,3 +234,20 @@ def test_pyscript_custom_name(ps_echo, request): out = run_cmd(ps_echo, 'pyscript {}'.format(python_script)) assert out assert message == out[0] + + +def test_pyscript_argparse_checks(ps_app, capsys): + # Test command that has nargs.REMAINDER and make sure all tokens are accepted + run_cmd(ps_app, 'py app.alias.create("my_alias", "alias_command", "command_arg1", "command_arg2")') + out = run_cmd(ps_app, 'alias list my_alias') + assert out == normalize('alias create my_alias alias_command command_arg1 command_arg2') + + # Specify flag outside of keyword argument + run_cmd(ps_app, 'py app.help("-h")') + _, err = capsys.readouterr() + assert '-h appears to be a flag' in err + + # Specify list with flag outside of keyword argument + run_cmd(ps_app, 'py app.help(["--help"])') + _, err = capsys.readouterr() + assert '--help appears to be a flag' in err |