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:
|
2018-08-30 09:18:49 -05:00
|
|
|
pytest.mark.skip(msg="prompt_toolkit is not available")
|
2015-05-17 23:51:21 +02:00
|
|
|
|
2018-07-14 22:08:30 -04:00
|
|
|
from xonsh.ptk2.history import PromptToolkitHistory
|
2015-05-17 23:51:21 +02:00
|
|
|
|
2018-07-15 16:37:21 -05:00
|
|
|
from tools import skip_if_lt_ptk2
|
|
|
|
|
2015-05-17 23:51:21 +02:00
|
|
|
|
2016-06-25 01:15:48 +03:00
|
|
|
@pytest.fixture
|
|
|
|
def history_obj():
|
2017-06-07 11:51:17 -04:00
|
|
|
"""Instantiate `PromptToolkitHistory` and append a line string"""
|
2016-06-25 01:15:48 +03:00
|
|
|
hist = PromptToolkitHistory(load_prev=False)
|
2018-08-30 09:18:49 -05:00
|
|
|
hist.append_string("line10")
|
2016-06-25 01:15:48 +03:00
|
|
|
return hist
|
|
|
|
|
|
|
|
|
2018-07-15 16:37:21 -05:00
|
|
|
@skip_if_lt_ptk2
|
2016-06-25 01:15:48 +03:00
|
|
|
def test_obj(history_obj):
|
2018-08-30 09:18:49 -05:00
|
|
|
assert ["line10"] == history_obj.get_strings()
|
2016-06-22 23:17:33 +03:00
|
|
|
assert len(history_obj) == 1
|
2018-08-30 09:18:49 -05:00
|
|
|
assert ["line10"] == [x for x in history_obj]
|