Esempio n. 1
0
def test_shell_with_sqlite_history(xession, xonsh_execer, tmpdir_factory):
    """
    Check that shell successfully load SQLite history from file.
    """
    tempdir = str(tmpdir_factory.mktemp("history"))

    history_file = os.path.join(tempdir, "history.db")
    h = SqliteHistory(filename=history_file)
    h.append({
        "inp": "echo Hello world 1\n",
        "rtn": 0,
        "ts": [1615887820.7329783, 1615887820.7513437],
    })
    h.append({
        "inp": "echo Hello world 2\n",
        "rtn": 0,
        "ts": [1615887820.7329783, 1615887820.7513437],
    })
    h.flush()

    xession.env.update(
        dict(
            XONSH_DATA_DIR=tempdir,
            XONSH_INTERACTIVE=True,
            XONSH_HISTORY_BACKEND="sqlite",
            XONSH_HISTORY_FILE=history_file,
            # XONSH_DEBUG=1  # to show errors
        ))

    Shell(xonsh_execer, shell_type="none")

    assert len([i for i in xession.history.all_items()]) == 2
Esempio n. 2
0
def hist():
    h = SqliteHistory(filename="xonsh-HISTORY-TEST.sqlite",
                      sessionid="SESSIONID",
                      gc=False)
    yield h
    os.remove(h.filename)