Skip to content

Commit 5663d9f

Browse files
committed
Added unit test for _input_line_to_statement
1 parent d679f72 commit 5663d9f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/test_cmd2.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,20 @@ def test_multiline_complete_statement_with_unclosed_quotes(multiline_app):
12881288
assert statement.multiline_command == 'orate'
12891289
assert statement.terminator == ';'
12901290

1291+
def test_multiline_input_line_to_statement(multiline_app):
1292+
# Verify _input_line_to_statement saves the fully entered input line for multiline commands
1293+
1294+
# Mock out the input call so we don't actually wait for a user's response
1295+
# on stdin when it looks for more input
1296+
m = mock.MagicMock(name='input', side_effect=['person', '\n'])
1297+
builtins.input = m
1298+
1299+
line = 'orate hi'
1300+
statement = multiline_app._input_line_to_statement(line)
1301+
assert statement.raw == 'orate hi\nperson\n'
1302+
assert statement == 'hi person'
1303+
assert statement.command == 'orate'
1304+
assert statement.multiline_command == 'orate'
12911305

12921306
def test_clipboard_failure(base_app, capsys):
12931307
# Force cmd2 clipboard to be disabled

0 commit comments

Comments
 (0)