summaryrefslogtreecommitdiff
path: root/tests/test_history.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_history.py')
-rw-r--r--tests/test_history.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/test_history.py b/tests/test_history.py
index 5e01688c..ce915d1a 100644
--- a/tests/test_history.py
+++ b/tests/test_history.py
@@ -10,6 +10,8 @@ import pytest
# Python 3.5 had some regressions in the unitest.mock module, so use
# 3rd party mock if available
+from cmd2.parsing import StatementParser
+
try:
import mock
except ImportError:
@@ -262,6 +264,35 @@ def histitem():
histitem = HistoryItem(statement, 1)
return histitem
+@pytest.fixture
+def parser():
+ from cmd2.parsing import StatementParser
+ parser = StatementParser(
+ allow_redirection=True,
+ terminators=[';', '&'],
+ multiline_commands=['multiline'],
+ aliases={'helpalias': 'help',
+ '42': 'theanswer',
+ 'l': '!ls -al',
+ 'anothermultiline': 'multiline',
+ 'fake': 'pyscript'},
+ shortcuts=[('?', 'help'), ('!', 'shell')]
+ )
+ return parser
+
+def test_multiline_histitem(parser):
+ from cmd2.history import History
+ line = 'multiline foo\nbar\n\n'
+ statement = parser.parse(line)
+ history = History()
+ history.append(statement)
+ assert len(history) == 1
+ hist_item = history[0]
+ assert hist_item.raw == line
+ pr_lines = hist_item.pr(verbose=True).splitlines()
+ assert pr_lines[0].endswith('multiline foo')
+ assert pr_lines[1] == 'bar'
+
def test_history_item_instantiate():
from cmd2.parsing import Statement
from cmd2.history import HistoryItem