How to use libtmux - 10 common examples

To help you get started, we’ve selected a few libtmux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmux-python / libtmux / tests / test_session.py View on Github external
def test_show_option_unknown(session):
    """Session.show_option raises UnknownOption for invalid option."""
    with pytest.raises(exc.UnknownOption):
        session.show_option('moooz')
github tmux-python / libtmux / tests / test_window.py View on Github external
def test_show_window_option_ambiguous(session):
    """show_window_option raises AmbiguousOption for ambiguous option."""
    window = session.new_window(window_name='test_window')

    with pytest.raises(exc.AmbiguousOption):
        window.show_window_option('clock-mode')
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_has_gte_version():
    assert has_gte_version('1.6')
    assert has_gte_version('1.6b')
    assert has_gte_version(str(get_version()))

    assert not has_gte_version('4.0')
    assert not has_gte_version('4.0b')
github tmux-python / tmuxp / tests / test_workspacebuilder.py View on Github external
if has_gte_version('2.3'):
        sconfig['windows'][0]['options']['pane-border-format'] = ' #P '

    builder = WorkspaceBuilder(sconf=sconfig)

    window_count = len(session._windows)  # current window count
    assert len(s._windows) == window_count
    for w, wconf in builder.iter_create_windows(s):
        for p in builder.iter_create_panes(w, wconf):
            w.select_layout('tiled')  # fix glitch with pane size
            p = p
            assert len(s._windows) == window_count
        assert isinstance(w, Window)
        assert w.show_window_option('main-pane-height') == 5
        if has_gte_version('2.3'):
            assert w.show_window_option('pane-border-format') == ' #P '

        assert len(s._windows) == window_count
        window_count += 1
        w.select_layout(wconf['layout'])
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_allows_master_version(monkeypatch):
    def mock_tmux_cmd(param):
        class Hi(object):
            stdout = ['tmux master']
            stderr = None

        return Hi()

    monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)

    assert has_minimum_version()
    assert has_gte_version(TMUX_MIN_VERSION)
    assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
    assert (
        '%s-master' % TMUX_MAX_VERSION == get_version()
    ), "Is the latest supported version with -master appended"
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_get_version_openbsd(monkeypatch):
    def mock_tmux_cmd(param):
        class Hi(object):
            stderr = ['tmux: unknown option -- V']

        return Hi()

    monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
    monkeypatch.setattr(sys, 'platform', 'openbsd 5.2')
    assert has_minimum_version()
    assert has_gte_version(TMUX_MIN_VERSION)
    assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
    assert (
        '%s-openbsd' % TMUX_MAX_VERSION == get_version()
    ), "Is the latest supported version with -openbsd appended"
github tmux-python / libtmux / tests / test_session.py View on Github external
def test_has_session(server, session):
    """Server.has_session returns True if has session_name exists."""
    TEST_SESSION_NAME = session.get('session_name')
    assert server.has_session(TEST_SESSION_NAME)
    if has_gte_version('2.1'):
        assert not server.has_session(TEST_SESSION_NAME[:-2])
        assert server.has_session(TEST_SESSION_NAME[:-2], exact=False)
    assert not server.has_session('asdf2314324321')
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_allows_next_version(monkeypatch):
    def mock_tmux_cmd(param):
        class Hi(object):
            stdout = ['tmux next-2.9']
            stderr = None

        return Hi()

    monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)

    assert has_minimum_version()
    assert has_gte_version(TMUX_MIN_VERSION)
    assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
    assert '2.9' == get_version()
github tmux-python / libtmux / tests / test_session.py View on Github external
def test_set_option_invalid(session):
    """Session.set_option raises UnknownOption for invalid option."""
    if has_gte_version('2.4'):
        with pytest.raises(exc.InvalidOption):
            session.set_option('afewewfew', 43)
    else:
        with pytest.raises(exc.UnknownOption):
            session.set_option('afewewfew', 43)
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_has_gte_version():
    assert has_gte_version('1.6')
    assert has_gte_version('1.6b')
    assert has_gte_version(str(get_version()))

    assert not has_gte_version('4.0')
    assert not has_gte_version('4.0b')