2016-07-03 12:26:52 +03:00
|
|
|
import pytest
|
2015-05-17 23:51:21 +02:00
|
|
|
|
2016-06-25 01:15:48 +03:00
|
|
|
try:
|
2016-11-14 22:28:09 +02:00
|
|
|
import prompt_toolkit # NOQA
|
2016-06-25 01:15:48 +03:00
|
|
|
except ImportError:
|
2016-11-14 22:28:09 +02:00
|
|
|
pytest.mark.skip(msg='prompt_toolkit is not available')
|
2015-05-17 23:51:21 +02:00
|
|
|
|
2015-12-29 23:46:44 -08:00
|
|
|
from xonsh.ptk.history import PromptToolkitHistory
|
2015-05-17 23:51:21 +02:00
|
|
|
|
|
|
|
|
2016-06-25 01:15:48 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def history_obj():
|
2016-07-03 12:00:24 +03:00
|
|
|
"""Instatiate `PromptToolkitHistory` and append a line string"""
|
2016-06-25 01:15:48 +03:00
|
|
|
hist = PromptToolkitHistory(load_prev=False)
|
|
|
|
hist.append('line10')
|
|
|
|
return hist
|
|
|
|
|
|
|
|
|
|
|
|
def test_obj(history_obj):
|
2016-06-22 23:17:33 +03:00
|
|
|
assert ['line10'] == history_obj.strings
|
|
|
|
assert len(history_obj) == 1
|
|
|
|
assert ['line10'] == [x for x in history_obj]
|