summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-26 13:12:31 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-09-26 13:12:31 -0400
commitee9c10115380635da070df05e83d9fd175187fb8 (patch)
tree12d06617e998c737003011df34ce7c909fa34d2b /tests
parente3d1bd12c2ecea2284d5af60cb5e903277ecb42c (diff)
downloadcmd2-git-ee9c10115380635da070df05e83d9fd175187fb8.tar.gz
Added ability to preserve quotes in argparse and arglist decorated functions to support aliases and macros
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 05a38457..5523d801 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1765,7 +1765,7 @@ def test_alias_create(base_app, capsys):
out = run_cmd(base_app, 'alias list')
assert out == normalize('alias create fake pyscript')
- # Lookup the new alias
+ # Look up the new alias
out = run_cmd(base_app, 'alias list fake')
assert out == normalize('alias create fake pyscript')
@@ -1774,7 +1774,7 @@ def test_alias_create_with_quotes(base_app, capsys):
out = run_cmd(base_app, 'alias create fake help ">" "out file.txt"')
assert out == normalize("Alias 'fake' created")
- # Lookup the new alias (Only the redirector should be unquoted)
+ # Look up the new alias (Only the redirector should be unquoted)
out = run_cmd(base_app, 'alias list fake')
assert out == normalize('alias create fake help > "out file.txt"')
@@ -1791,7 +1791,7 @@ def test_alias_create_with_quotes(base_app, capsys):
def test_alias_create_invalid_name(base_app, alias_name, capsys):
run_cmd(base_app, 'alias create {} help'.format(alias_name))
out, err = capsys.readouterr()
- assert "cannot" in err
+ assert "Invalid alias name" in err
def test_alias_create_with_macro_name(base_app, capsys):
macro = "my_macro"
@@ -1800,13 +1800,22 @@ def test_alias_create_with_macro_name(base_app, capsys):
out, err = capsys.readouterr()
assert "cannot have the same name" in err
-def test_alias_create_with_empty_command(base_app, capsys):
- run_cmd(base_app, 'alias create my_alias ""')
+@pytest.mark.parametrize('alias_target', [
+ '""', # Blank name
+ '">"',
+ '"no>pe"',
+ '"no spaces"',
+ '"nopipe|"',
+ '"noterm;"',
+ 'noembedded"quotes',
+])
+def test_alias_create_with_invalid_command(base_app, alias_target, capsys):
+ run_cmd(base_app, 'alias create my_alias {}'.format(alias_target))
out, err = capsys.readouterr()
- assert "cannot resolve to an empty command" in err
+ assert "Invalid alias target" in err
def test_alias_list_invalid_alias(base_app, capsys):
- # Lookup invalid alias
+ # Look up invalid alias
out = run_cmd(base_app, 'alias list invalid')
out, err = capsys.readouterr()
assert "not found" in err