diff options
author | Eric Lin <anselor@gmail.com> | 2018-05-16 10:39:49 -0400 |
---|---|---|
committer | Eric Lin <anselor@gmail.com> | 2018-05-16 10:39:49 -0400 |
commit | 371284d20370a8e85dd8527d9bbcc6267b335cde (patch) | |
tree | 002ac709eca15522a0b1abaa235aae04975b08e6 /tests/test_cmd2.py | |
parent | ab8194e92b9c3728d8f86cb9c81de180b6884eee (diff) | |
parent | a9b712108e5af49937b0af3aa51db2ebe5c159e4 (diff) | |
download | cmd2-git-371284d20370a8e85dd8527d9bbcc6267b335cde.tar.gz |
Merge branch 'master' into pyscript
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r-- | tests/test_cmd2.py | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index b6416005..6e4a5a3e 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -1430,7 +1430,7 @@ def test_clipboard_failure(capsys): # Make sure we got the error output out, err = capsys.readouterr() assert out == '' - assert 'Cannot redirect to paste buffer; install ``xclip`` and re-run to enable' in err + assert "Cannot redirect to paste buffer; install 'pyperclip' and re-run to enable" in err class CmdResultApp(cmd2.Cmd): @@ -1688,12 +1688,6 @@ def test_alias_lookup_invalid_alias(base_app, capsys): out, err = capsys.readouterr() assert "not found" in err -def test_alias_with_invalid_name(base_app, capsys): - run_cmd(base_app, 'alias @ help') - out, err = capsys.readouterr() - assert "can only contain the following characters" in err - - def test_unalias(base_app): # Create an alias run_cmd(base_app, 'alias fake pyscript') @@ -1711,6 +1705,18 @@ def test_unalias_non_existing(base_app, capsys): out, err = capsys.readouterr() assert "does not exist" in err +@pytest.mark.parametrize('alias_name', [ + '">"', + '"no>pe"', + '"no spaces"', + '"nopipe|"', + '"noterm;"', + 'noembedded"quotes', +]) +def test_create_invalid_alias(base_app, alias_name, capsys): + run_cmd(base_app, 'alias {} help'.format(alias_name)) + out, err = capsys.readouterr() + assert "can not contain" in err def test_ppaged(base_app): msg = 'testing...' @@ -1718,3 +1724,21 @@ def test_ppaged(base_app): base_app.ppaged(msg) out = base_app.stdout.buffer assert out == msg + end + +# we override cmd.parseline() so we always get consistent +# command parsing by parent methods we don't override +# don't need to test all the parsing logic here, because +# parseline just calls StatementParser.parse_command_only() +def test_parseline_empty(base_app): + statement = '' + command, args, line = base_app.parseline(statement) + assert not command + assert not args + assert not line + +def test_parseline(base_app): + statement = " command with 'partially completed quotes " + command, args, line = base_app.parseline(statement) + assert command == 'command' + assert args == "with 'partially completed quotes" + assert line == statement.strip() |