summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-14 15:19:22 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-06-14 15:19:22 -0400
commit5663d9faa6ae057b42129d9fecc68c7bb4485586 (patch)
treec61d4abe74bb3eee0a20d0ccab1cf74ddf351114 /tests
parentd679f727976cdee3a28e15e6d20094a39ddab70a (diff)
downloadcmd2-git-5663d9faa6ae057b42129d9fecc68c7bb4485586.tar.gz
Added unit test for _input_line_to_statement
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 1aafefc2..d5546f93 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1288,6 +1288,20 @@ def test_multiline_complete_statement_with_unclosed_quotes(multiline_app):
assert statement.multiline_command == 'orate'
assert statement.terminator == ';'
+def test_multiline_input_line_to_statement(multiline_app):
+ # Verify _input_line_to_statement saves the fully entered input line for multiline commands
+
+ # Mock out the input call so we don't actually wait for a user's response
+ # on stdin when it looks for more input
+ m = mock.MagicMock(name='input', side_effect=['person', '\n'])
+ builtins.input = m
+
+ line = 'orate hi'
+ statement = multiline_app._input_line_to_statement(line)
+ assert statement.raw == 'orate hi\nperson\n'
+ assert statement == 'hi person'
+ assert statement.command == 'orate'
+ assert statement.multiline_command == 'orate'
def test_clipboard_failure(base_app, capsys):
# Force cmd2 clipboard to be disabled