Ejemplo n.º 1
0
def persisted_hist():
    from cmd2.parsing import Statement
    from cmd2.cmd2 import History, HistoryItem
    h = History([HistoryItem(Statement('', raw='first'), 1),
                 HistoryItem(Statement('', raw='second'), 2),
                 HistoryItem(Statement('', raw='third'), 3),
                 HistoryItem(Statement('', raw='fourth'),4)])
    h.start_session()
    h.append(Statement('', raw='fifth'))
    h.append(Statement('', raw='sixth'))
    return h
Ejemplo n.º 2
0
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().splitlines()
    assert pr_lines[0].endswith('multiline foo bar')
Ejemplo n.º 3
0
def test_multiline_histitem_verbose(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(1, verbose=True).splitlines()
    assert pr_lines[0].endswith('multiline foo')
    assert pr_lines[1] == 'bar'