summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py3
-rw-r--r--tests/test_parsing.py24
2 files changed, 26 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index c3c9a29f..bc76505f 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1707,10 +1707,11 @@ def test_unalias_non_existing(base_app, capsys):
@pytest.mark.parametrize('alias_name', [
'">"',
- '"no>pe"'
+ '"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))
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index ad4d31cd..bfb55b23 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -439,3 +439,27 @@ def test_parse_command_only_quoted_args(parser):
assert statement.command == 'shell'
assert statement.args == 'ls -al "/tmp/directory with spaces/doit.sh"'
assert statement.command_and_args == line.replace('l', 'shell ls -al')
+
+@pytest.mark.parametrize('line', [
+ 'helpalias > out.txt',
+ 'helpalias>out.txt',
+ 'helpalias >> out.txt',
+ 'helpalias>>out.txt',
+ 'help|less',
+ 'helpalias;',
+])
+def test_parse_command_only_specialchars(parser, line):
+ statement = parser.parse_command_only(line)
+ assert statement.command == 'help'
+
+@pytest.mark.parametrize('line', [
+ ';',
+ '>',
+ "'",
+ '"',
+ '|',
+])
+def test_parse_command_only_none(parser, line):
+ statement = parser.parse_command_only(line)
+ assert statement.command == None
+ assert statement.args == None