Skip to content

Commit f9491e9

Browse files
sloriatony
authored andcommitted
Handle next-X.Y versions
tmuxp currently crashes when used with tmux next-2.9 (the latest Homebrew release). ``` TypeError: '<' not supported between instances of 'str' and 'int' ``` This patch avoids the error by making `get_version()` strip the "next-" part of the version. closes tmux-python/tmuxp#449
1 parent 9097c31 commit f9491e9

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

libtmux/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ def get_version():
471471
if version == 'master':
472472
return LooseVersion('%s-master' % TMUX_MAX_VERSION)
473473

474-
version = re.sub(r'[a-z]', '', version)
474+
version = re.sub(r'[a-z-]', '', version)
475475

476476
return LooseVersion(version)
477477

tests/test_common.py

+18
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,24 @@ class Hi(object):
4545
), "Is the latest supported version with -master appended"
4646

4747

48+
def test_allows_next_version(monkeypatch):
49+
def mock_tmux_cmd(param):
50+
class Hi(object):
51+
stdout = ['tmux next-2.9']
52+
stderr = None
53+
54+
return Hi()
55+
56+
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
57+
58+
assert has_minimum_version()
59+
assert has_gte_version(TMUX_MIN_VERSION)
60+
assert has_gt_version(TMUX_MAX_VERSION), "Greater than the max-supported version"
61+
assert (
62+
'2.9' == get_version()
63+
)
64+
65+
4866
def test_get_version_openbsd(monkeypatch):
4967
def mock_tmux_cmd(param):
5068
class Hi(object):

0 commit comments

Comments
 (0)