Пример #1
0
def test_read_actions(patch_get_key):
    patch_get_key(
        [
            # Enter:
            "\n",
            # Enter:
            "\r",
            # Ignored:
            "x",
            "y",
            # Up:
            const.KEY_UP,
            "k",
            # Down:
            const.KEY_DOWN,
            "j",
            # Ctrl+C:
            const.KEY_CTRL_C,
            "q",
        ]
    )
    assert list(islice(ui.read_actions(), 8)) == [
        const.ACTION_SELECT,
        const.ACTION_SELECT,
        const.ACTION_PREVIOUS,
        const.ACTION_PREVIOUS,
        const.ACTION_NEXT,
        const.ACTION_NEXT,
        const.ACTION_ABORT,
        const.ACTION_ABORT,
    ]
Пример #2
0
def test_read_actions(patch_get_key):
    patch_get_key([
        # Enter:
        "\n",
        # Enter:
        "\r",
        # Ignored:
        "x",
        "y",
        # Up:
        const.KEY_UP,
        "k",
        # Down:
        const.KEY_DOWN,
        "j",
        # Ctrl+C:
        const.KEY_CTRL_C,
        "q",
    ])
    assert list(islice(ui.read_actions(), 8)) == [
        const.ACTION_SELECT,
        const.ACTION_SELECT,
        const.ACTION_PREVIOUS,
        const.ACTION_PREVIOUS,
        const.ACTION_NEXT,
        const.ACTION_NEXT,
        const.ACTION_ABORT,
        const.ACTION_ABORT,
    ]
Пример #3
0
def test_read_actions(patch_getch):
    patch_getch([  # Enter:
                   '\n',
                   # Enter:
                   '\r',
                   # Ignored:
                   'x', 'y',
                   # Up:
                   '\x1b', '[', 'A',
                   # Down:
                   '\x1b', '[', 'B',
                   # Ctrl+C:
                   KeyboardInterrupt], )
    assert list(islice(ui.read_actions(), 5)) \
           == [ui.SELECT, ui.SELECT, ui.PREVIOUS, ui.NEXT, ui.ABORT]
Пример #4
0
def test_read_actions(patch_get_key):
    patch_get_key([
        # Enter:
        '\n',
        # Enter:
        '\r',
        # Ignored:
        'x', 'y',
        # Up:
        const.KEY_UP,
        # Down:
        const.KEY_DOWN,
        # Ctrl+C:
        const.KEY_CTRL_C])
    assert list(islice(ui.read_actions(), 5)) \
           == [ui.SELECT, ui.SELECT, ui.PREVIOUS, ui.NEXT, ui.ABORT]
Пример #5
0
def test_read_actions(patch_get_key):
    patch_get_key([
        # Enter:
        '\n',
        # Enter:
        '\r',
        # Ignored:
        'x', 'y',
        # Up:
        const.KEY_UP, 'k',
        # Down:
        const.KEY_DOWN, 'j',
        # Ctrl+C:
        const.KEY_CTRL_C, 'q'])
    assert (list(islice(ui.read_actions(), 8))
            == [const.ACTION_SELECT, const.ACTION_SELECT,
                const.ACTION_PREVIOUS, const.ACTION_PREVIOUS,
                const.ACTION_NEXT, const.ACTION_NEXT,
                const.ACTION_ABORT, const.ACTION_ABORT])
Пример #6
0
def test_read_actions(patch_get_key):
    patch_get_key([
        # Enter:
        '\n',
        # Enter:
        '\r',
        # Ignored:
        'x', 'y',
        # Up:
        const.KEY_UP, 'k',
        # Down:
        const.KEY_DOWN, 'j',
        # Ctrl+C:
        const.KEY_CTRL_C, 'q'])
    assert (list(islice(ui.read_actions(), 8))
            == [const.ACTION_SELECT, const.ACTION_SELECT,
                const.ACTION_PREVIOUS, const.ACTION_PREVIOUS,
                const.ACTION_NEXT, const.ACTION_NEXT,
                const.ACTION_ABORT, const.ACTION_ABORT])
Пример #7
0
def test_read_actions(patch_getch):
    patch_getch(
        [  # Enter:
            '\n',
            # Enter:
            '\r',
            # Ignored:
            'x',
            'y',
            # Up:
            '\x1b',
            '[',
            'A',
            # Down:
            '\x1b',
            '[',
            'B',
            # Ctrl+C:
            KeyboardInterrupt
        ], )
    assert list(islice(ui.read_actions(), 5)) \
           == [ui.SELECT, ui.SELECT, ui.PREVIOUS, ui.NEXT, ui.ABORT]