summaryrefslogtreecommitdiff
path: root/tests/test_cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-08-09 00:25:57 -0400
committerGitHub <noreply@github.com>2018-08-09 00:25:57 -0400
commit88b739f6a11a2a1796b2758fa2ce94c562e24316 (patch)
tree13a9f8ab97ac1bf2d496ccd3bfd8cfe105064666 /tests/test_cmd2.py
parent46955ec2f403a94ca3582fe3225bdcc369f334e1 (diff)
parent34784566f926b57234388150a550ca005f6f3ef9 (diff)
downloadcmd2-git-88b739f6a11a2a1796b2758fa2ce94c562e24316.tar.gz
Merge pull request #496 from python-cmd2/embedded_newlines
Fix #495 by allowing embedded newlines in unclosed quote marks when entering multiline commands
Diffstat (limited to 'tests/test_cmd2.py')
-rw-r--r--tests/test_cmd2.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index 3324a105..0ec993e9 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -1471,7 +1471,8 @@ def test_multiline_complete_empty_statement_raises_exception(multiline_app):
multiline_app._complete_statement('')
def test_multiline_complete_statement_without_terminator(multiline_app):
- # Mock out the input call so we don't actually wait for a user's response on stdin when it looks for more input
+ # 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', return_value='\n')
builtins.input = m
@@ -1481,6 +1482,20 @@ def test_multiline_complete_statement_without_terminator(multiline_app):
statement = multiline_app._complete_statement(line)
assert statement == args
assert statement.command == command
+ assert statement.multiline_command == command
+
+def test_multiline_complete_statement_with_unclosed_quotes(multiline_app):
+ # 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=['quotes', '" now closed;'])
+ builtins.input = m
+
+ line = 'orate hi "partially open'
+ statement = multiline_app._complete_statement(line)
+ assert statement == 'hi "partially open\nquotes\n" now closed'
+ assert statement.command == 'orate'
+ assert statement.multiline_command == 'orate'
+ assert statement.terminator == ';'
def test_clipboard_failure(base_app, capsys):