def test_get_version_too_low(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) with pytest.raises(LibTmuxException) as exc_info: get_version() exc_info.match('is running tmux 1.3 or earlier')
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')
def test_has_lte_version(): assert has_lte_version('4.0a') assert has_lte_version('4.0') assert has_lte_version(str(get_version())) assert not has_lte_version('1.7') assert not has_lte_version('1.7b')
def test_has_lte_version(): assert has_lte_version("4.0a") assert has_lte_version("4.0") assert has_lte_version(str(get_version())) assert not has_lte_version("1.7") assert not has_lte_version("1.7b")
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")
def command_debug_info(): """ Print debug info to submit with Issues. """ def prepend_tab(strings): """ Prepend tab to strings in list. """ return list(map(lambda x: "\t%s" % x, strings)) def output_break(): """ Generate output break. """ return "-" * 25 def format_tmux_resp(std_resp): """ Format tmux command response for tmuxp stdout. """ return "\n".join([ "\n".join(prepend_tab(std_resp.stdout)), click.style("\n".join(prepend_tab(std_resp.stderr)), fg="red"), ]) output = [ output_break(), "environment:\n%s" % "\n".join( prepend_tab([ "dist: %s" % platform.platform(), "arch: %s" % platform.machine(), "uname: %s" % "; ".join(platform.uname()[:3]), "version: %s" % platform.version(), ])), output_break(), "python version: %s" % " ".join(sys.version.split("\n")), "system PATH: %s" % os.environ["PATH"], "tmux version: %s" % get_version(), "libtmux version: %s" % libtmux_version, "tmuxp version: %s" % __version__, "tmux path: %s" % which("tmux"), "tmuxp path: %s" % tmuxp_path, "shell: %s" % os.environ["SHELL"], output_break(), "tmux sessions:\n%s" % format_tmux_resp(tmux_cmd("list-sessions")), "tmux windows:\n%s" % format_tmux_resp(tmux_cmd("list-windows")), "tmux panes:\n%s" % format_tmux_resp(tmux_cmd("list-panes")), "tmux global options:\n%s" % format_tmux_resp(tmux_cmd("show-options", "-g")), "tmux window options:\n%s" % format_tmux_resp(tmux_cmd("show-window-options", "-g")), ] tmuxp_echo("\n".join(output))
def command_debug_info(): """ Print debug info to submit with Issues. """ def prepend_tab(strings): """ Prepend tab to strings in list. """ return list(map(lambda x: '\t%s' % x, strings)) def output_break(): """ Generate output break. """ return '-' * 25 def format_tmux_resp(std_resp): """ Format tmux command response for tmuxp stdout. """ return '\n'.join([ '\n'.join(prepend_tab(std_resp.stdout)), click.style('\n'.join(prepend_tab(std_resp.stderr)), fg='red'), ]) output = [ output_break(), 'environment:\n%s' % '\n'.join( prepend_tab([ 'dist: %s' % platform.platform(), 'arch: %s' % platform.machine(), 'uname: %s' % '; '.join(platform.uname()[:3]), 'version: %s' % platform.version(), ])), output_break(), 'python version: %s' % ' '.join(sys.version.split('\n')), 'system PATH: %s' % os.environ['PATH'], 'tmux version: %s' % get_version(), 'libtmux version: %s' % libtmux_version, 'tmuxp version: %s' % __version__, 'tmux path: %s' % which('tmux'), 'tmuxp path: %s' % tmuxp_path, 'shell: %s' % os.environ['SHELL'], output_break(), 'tmux sessions:\n%s' % format_tmux_resp(tmux_cmd('list-sessions')), 'tmux windows:\n%s' % format_tmux_resp(tmux_cmd('list-windows')), 'tmux panes:\n%s' % format_tmux_resp(tmux_cmd('list-panes')), 'tmux global options:\n%s' % format_tmux_resp(tmux_cmd('show-options', '-g')), 'tmux window options:\n%s' % format_tmux_resp(tmux_cmd('show-window-options', '-g')), ] tmuxp_echo('\n'.join(output))
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()
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")
def test_get_version_openbsd(monkeypatch): def mock_tmux_cmd(param): class Hi: 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"
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"
def test_allows_master_version(monkeypatch): def mock_tmux_cmd(param): class Hi: 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"
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")
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"
def test_has_version(): assert has_version(str(get_version()))
def __init__( self, plugin_name="tmuxp-plugin", tmux_min_version=TMUX_MIN_VERSION, tmux_max_version=TMUX_MAX_VERSION, tmux_version_incompatible=None, libtmux_min_version=LIBTMUX_MIN_VERSION, libtmux_max_version=LIBTMUX_MAX_VERSION, libtmux_version_incompatible=None, tmuxp_min_version=TMUXP_MIN_VERSION, tmuxp_max_version=TMUXP_MAX_VERSION, tmuxp_version_incompatible=None, ): """ Initialize plugin. The default version values are set to the versions that the plugin system requires. Parameters ---------- plugin_name : str Name of the child plugin. Used in error message plugin fails to load tmux_min_version : str Min version of tmux that the plugin supports tmux_max_version : str Min version of tmux that the plugin supports tmux_version_incompatible : list Versions of tmux that are incompatible with the plugin libtmux_min_version : str Min version of libtmux that the plugin supports libtmux_max_version : str Max version of libtmux that the plugin supports libtmux_version_incompatible : list Versions of libtmux that are incompatible with the plugin tmuxp_min_version : str Min version of tmuxp that the plugin supports tmuxp_max_version : str Max version of tmuxp that the plugin supports tmuxp_version_incompatible : list Versions of tmuxp that are incompatible with the plugin """ self.plugin_name = plugin_name # Dependency versions self.tmux_version = get_version() self.libtmux_version = libtmux.__version__ self.tmuxp_version = LooseVersion(__version__) self.version_constraints = { "tmux": { "version": self.tmux_version, "vmin": tmux_min_version, "vmax": tmux_max_version, "incompatible": tmux_version_incompatible if tmux_version_incompatible else [], }, "libtmux": { "version": self.libtmux_version, "vmin": libtmux_min_version, "vmax": libtmux_max_version, "incompatible": libtmux_version_incompatible if libtmux_version_incompatible else [], }, "tmuxp": { "version": self.tmuxp_version, "vmin": tmuxp_min_version, "vmax": tmuxp_max_version, "incompatible": tmuxp_version_incompatible if tmuxp_version_incompatible else [], }, } self._version_check()