Пример #1
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
Пример #2
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
Пример #3
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
Пример #4
0
def test_history_item_instantiate():
    from cmd2.parsing import Statement
    from cmd2.history import HistoryItem
    statement = Statement('history',
                            raw='help history',
                            command='help',
                            arg_list=['history'],
                            )
    with pytest.raises(TypeError):
        _ = HistoryItem()
    with pytest.raises(TypeError):
        _ = HistoryItem(idx=1)
    with pytest.raises(TypeError):
        _ = HistoryItem(statement=statement)
    with pytest.raises(TypeError):
        _ = HistoryItem(statement=statement, idx='hi')
Пример #5
0
def histitem():
    from cmd2.parsing import Statement
    from cmd2.history import HistoryItem
    statement = Statement('history',
                            raw='help history',
                            command='help',
                            arg_list=['history'],
                            )
    histitem = HistoryItem(statement, 1)
    return histitem
Пример #6
0
def test_history_item_instantiate():
    from cmd2.history import (
        HistoryItem, )
    from cmd2.parsing import (
        Statement, )

    statement = Statement(
        'history',
        raw='help history',
        command='help',
        arg_list=['history'],
    )
    with pytest.raises(TypeError):
        _ = HistoryItem()