diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-03-03 15:53:18 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2019-03-03 15:53:18 -0500 |
commit | 73496248ba76cc58512142be3973a214ae9336f8 (patch) | |
tree | 4d4ba0f5bfd19b8dea8862265499ac6d072f11a3 /tests | |
parent | 009cb87895c2e23521f2fe1b69252231fa010a5a (diff) | |
download | cmd2-git-73496248ba76cc58512142be3973a214ae9336f8.tar.gz |
Fixed a couple bugs and added unit tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_parsing.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 78adf880..c341f9e3 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -10,8 +10,10 @@ import attr import pytest import cmd2 -from cmd2.parsing import StatementParser from cmd2 import utils +from cmd2.constants import MULTILINE_TERMINATOR +from cmd2.parsing import StatementParser + @pytest.fixture def parser(): @@ -147,6 +149,7 @@ def test_parse_word_plus_terminator(parser, line, terminator): assert statement.argv == ['termbare'] assert not statement.arg_list assert statement.terminator == terminator + assert statement.expanded_command_line == statement.command + statement.terminator @pytest.mark.parametrize('line,terminator', [ ('termbare; suffx', ';'), @@ -163,6 +166,7 @@ def test_parse_suffix_after_terminator(parser, line, terminator): assert not statement.arg_list assert statement.terminator == terminator assert statement.suffix == 'suffx' + assert statement.expanded_command_line == statement.command + statement.terminator + ' ' + statement.suffix def test_parse_command_with_args(parser): line = 'command with args' @@ -258,6 +262,7 @@ def test_parse_simple_pipe(parser, line): assert statement.argv == ['simple'] assert not statement.arg_list assert statement.pipe_to == ['piped'] + assert statement.expanded_command_line == statement.command + ' | ' + ' '.join(statement.pipe_to) def test_parse_double_pipe_is_not_a_pipe(parser): line = 'double-pipe || is not a pipe' @@ -294,6 +299,7 @@ def test_parse_redirect(parser,line, output): assert statement.args == statement assert statement.output == output assert statement.output_to == 'out.txt' + assert statement.expanded_command_line == statement.command + ' ' + statement.output + ' ' + statement.output_to def test_parse_redirect_with_args(parser): line = 'output into > afile.txt' @@ -539,6 +545,7 @@ def test_parse_alias_on_multiline_command(parser): assert statement.args == statement assert statement == 'has > inside an unfinished command' assert statement.terminator == '' + assert statement.expanded_command_line == statement.multiline_command + ' ' + statement + MULTILINE_TERMINATOR @pytest.mark.parametrize('line,output', [ ('helpalias > out.txt', '>'), |