summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkotfu <kotfu@kotfu.net>2018-05-06 10:15:42 -0600
committerkotfu <kotfu@kotfu.net>2018-05-06 10:15:42 -0600
commit3343aad02757739fd7ddb91b095db277a59574d9 (patch)
tree62e762bc04340826624d3ec6bfd0e3e58d4970a1
parente945560fe80087bbd0bf91c41e37b17131e83e69 (diff)
downloadcmd2-git-3343aad02757739fd7ddb91b095db277a59574d9.tar.gz
Add more unit tests
-rw-r--r--tests/test_parsing.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py
index 4b972d51..f560f993 100644
--- a/tests/test_parsing.py
+++ b/tests/test_parsing.py
@@ -38,7 +38,10 @@ def test_parse_empty_string(parser):
('command /* with some comment */ arg', ['command', 'arg']),
('command arg1 arg2 # comment at the end', ['command', 'arg1', 'arg2']),
('42 arg1 arg2', ['theanswer', 'arg1', 'arg2']),
- ('l', ['shell', 'ls', '-al'])
+ ('l', ['shell', 'ls', '-al']),
+ ('termbare ; > /tmp/output', ['termbare', ';', '>', '/tmp/output']),
+ ('help|less', ['help', '|', 'less']),
+ ('l|less', ['shell', 'ls', '-al', '|', 'less']),
])
def test_tokenize(parser, line, tokens):
tokens_to_test = parser.tokenize(line)
@@ -69,15 +72,21 @@ def test_parse_single_word(parser, line):
assert not statement.args
assert statement.argv == [utils.strip_quotes(line)]
-def test_parse_word_plus_terminator(parser):
- line = 'termbare;'
+@pytest.mark.parametrize('line', [
+ 'termbare;',
+ 'termbare ;',
+])
+def test_parse_word_plus_terminator(parser, line):
statement = parser.parse(line)
assert statement.command == 'termbare'
assert statement.terminator == ';'
assert statement.argv == ['termbare']
-def test_parse_suffix_after_terminator(parser):
- line = 'termbare; suffx'
+@pytest.mark.parametrize('line', [
+ 'termbare; suffx',
+ 'termbare ;suffx',
+])
+def test_parse_suffix_after_terminator(parser, line):
statement = parser.parse(line)
assert statement.command == 'termbare'
assert statement.terminator == ';'