Skip to content

Commit ad7f4f6

Browse files
committed
add TMUX_MAX_VERSION and TMUX_MIN_VERSION
1 parent d26abdc commit ad7f4f6

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

doc/api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ Pane Object
5252
Internals
5353
---------
5454

55+
56+
.. autodata:: libtmux.common.TMUX_MIN_VERSION
57+
58+
.. autodata:: libtmux.common.TMUX_MAX_VERSION
59+
5560
.. autoclass:: libtmux.common.TmuxRelationalObject
5661
:members:
5762

libtmux/common.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@
1919
logger = logging.getLogger(__name__)
2020

2121

22+
#: Minimum version of tmux required to run libtmux
23+
TMUX_MIN_VERSION = '1.8'
24+
25+
#: Most recent version of tmux supported
26+
TMUX_MAX_VERSION = '2.4'
27+
28+
2229
class EnvironmentMixin(object):
2330

2431
"""Mixin class for managing session and server level environment
@@ -405,10 +412,11 @@ def get_version():
405412
if proc.stderr:
406413
if proc.stderr[0] == 'tmux: unknown option -- V':
407414
if sys.platform.startswith("openbsd"): # openbsd has no tmux -V
408-
return LooseVersion('2.3')
415+
return LooseVersion(TMUX_MAX_VERSION)
409416
raise exc.LibTmuxException(
410-
'libtmux supports tmux 1.8 and greater. This system'
411-
' is running tmux 1.3 or earlier.')
417+
'libtmux supports tmux %s and greater. This system'
418+
' is running tmux 1.3 or earlier.' % TMUX_MIN_VERSION
419+
)
412420
raise exc.VersionTooLow(proc.stderr)
413421

414422
version = proc.stdout[0].split('tmux ')[1]
@@ -494,12 +502,12 @@ def has_minimum_version(raises=True):
494502
495503
"""
496504

497-
if get_version() <= LooseVersion("1.7"):
505+
if get_version() < LooseVersion(TMUX_MIN_VERSION):
498506
if raises:
499507
raise exc.VersionTooLow(
500-
'libtmux only supports tmux 1.8 and greater. This system'
508+
'libtmux only supports tmux %s and greater. This system'
501509
' has %s installed. Upgrade your tmux to use libtmux.' %
502-
get_version()
510+
(TMUX_MIN_VERSION, get_version())
503511
)
504512
else:
505513
return False

tests/test_common.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from libtmux.common import (
1414
has_minimum_version, which, session_check_name, tmux_cmd,
1515
has_version, has_gt_version, has_lt_version, get_version,
16-
has_gte_version, has_lte_version
16+
has_gte_version, has_lte_version, TMUX_MAX_VERSION
1717
)
1818
from libtmux.exc import LibTmuxException, BadSessionName, TmuxCommandNotFound
1919

@@ -37,7 +37,7 @@ class Hi(object):
3737
return proc
3838
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
3939
monkeypatch.setattr(sys, 'platform', 'openbsd 5.2')
40-
assert get_version() == LooseVersion('2.3')
40+
assert get_version() == LooseVersion(TMUX_MAX_VERSION)
4141

4242

4343
def test_get_version_too_low(monkeypatch):

0 commit comments

Comments
 (0)