xonsh/tests/shell/test_ptk_history.py
Andy Kipp 1d7cc00962
refactoring: move shell to shells.shell to avoid unwanted init (#5556)
Continue #5550 for https://github.com/xonsh/xonsh/issues/5538 

---------

Co-authored-by: a <1@1.1>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Noorhteen Raja NJ <jnoortheen@gmail.com>
2024-06-29 14:26:50 +05:30

22 lines
571 B
Python

import pytest
try:
import prompt_toolkit # NOQA
except ImportError:
pytest.mark.skip(msg="prompt_toolkit is not available")
@pytest.fixture
def history_obj():
"""Instantiate `PromptToolkitHistory` and append a line string"""
from xonsh.shells.ptk_shell.history import PromptToolkitHistory
hist = PromptToolkitHistory(load_prev=False)
hist.append_string("line10")
return hist
def test_obj(history_obj):
assert ["line10"] == history_obj.get_strings()
assert len(history_obj) == 1
assert ["line10"] == [x for x in history_obj]