Beispiel #1
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')
Beispiel #2
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'
Beispiel #3
0
def 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)])
    return h
Beispiel #4
0
def hist():
    from cmd2.cmd2 import (
        History,
        HistoryItem,
    )
    from cmd2.parsing import (
        Statement, )

    h = History([
        HistoryItem(Statement('', raw='first')),
        HistoryItem(Statement('', raw='second')),
        HistoryItem(Statement('', raw='third')),
        HistoryItem(Statement('', raw='fourth')),
    ])
    return h
Beispiel #5
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