How to use the libtmux.common.has_minimum_version function in libtmux

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_common.py View on Github external
def test_ignores_letter_versions():
    """Ignore letters such as 1.8b.

    See ticket https://github.com/tmux-python/tmuxp/issues/55.

    In version 0.1.7 this is adjusted to use LooseVersion, in order to
    allow letters.

    """
    result = has_minimum_version('1.9a')
    assert result

    result = has_minimum_version('1.8a')
    assert result

    # Should not throw
    assert type(has_version('1.8')) is bool
    assert type(has_version('1.8a')) is bool
    assert type(has_version('1.9a')) is bool
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_common.py View on Github external
def test_error_version_less_1_7(monkeypatch):
    def mock_get_version():
        return LooseVersion('1.7')

    monkeypatch.setattr(libtmux.common, 'get_version', mock_get_version)
    with pytest.raises(LibTmuxException) as excinfo:
        has_minimum_version()
        excinfo.match(r'libtmux only supports')

    with pytest.raises(LibTmuxException) as excinfo:
        has_minimum_version()

        excinfo.match(r'libtmux only supports')
github tmux-python / libtmux / tests / test_common.py View on Github external
def test_ignores_letter_versions():
    """Ignore letters such as 1.8b.

    See ticket https://github.com/tmux-python/tmuxp/issues/55.

    In version 0.1.7 this is adjusted to use LooseVersion, in order to
    allow letters.

    """
    result = has_minimum_version('1.9a')
    assert result

    result = has_minimum_version('1.8a')
    assert result

    # Should not throw
    assert type(has_version('1.8')) is bool
    assert type(has_version('1.8a')) is bool
    assert type(has_version('1.9a')) is bool
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_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 / tmuxp / tmuxp / cli.py View on Github external
def cli(log_level):
    """Manage tmux sessions.

    Pass the "--help" argument to any command to see detailed help.
    See detailed documentation and examples at:
    http://tmuxp.readthedocs.io/en/latest/"""
    try:
        has_minimum_version()
    except TmuxCommandNotFound:
        click.echo('tmux not found. tmuxp requires you install tmux first.')
        sys.exit()
    except exc.TmuxpException as e:
        click.echo(e, err=True)
        sys.exit()
    setup_logger(level=log_level.upper())