Skip to content

Commit 7e97e50

Browse files
committed
improve openbsd version in get_version
1 parent 5096e70 commit 7e97e50

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

libtmux/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,17 @@ def get_version():
408408
If tmux is built from git master, the version returned will be the latest
409409
version appended with -master, e.g. ``2.4-master``.
410410
411+
If using OpenBSD's base system tmux, the version will have ``-openbsd``
412+
appended to the latest version, e.g. ``2.4-openbsd``.
413+
411414
:returns: tmux version
412415
:rtype: :class:`distutils.version.LooseVersion`
413416
"""
414417
proc = tmux_cmd('-V')
415418
if proc.stderr:
416419
if proc.stderr[0] == 'tmux: unknown option -- V':
417420
if sys.platform.startswith("openbsd"): # openbsd has no tmux -V
418-
return LooseVersion(TMUX_MAX_VERSION)
421+
return LooseVersion('%s-openbsd' % TMUX_MAX_VERSION)
419422
raise exc.LibTmuxException(
420423
'libtmux supports tmux %s and greater. This system'
421424
' is running tmux 1.3 or earlier.' % TMUX_MIN_VERSION

tests/test_common.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,14 @@ class Hi(object):
4545
return Hi()
4646
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
4747
monkeypatch.setattr(sys, 'platform', 'openbsd 5.2')
48-
assert get_version() == LooseVersion(TMUX_MAX_VERSION)
48+
assert has_minimum_version()
49+
assert has_gte_version(TMUX_MIN_VERSION)
50+
assert has_gt_version(TMUX_MAX_VERSION), (
51+
"Greater than the max-supported version"
52+
)
53+
assert '%s-openbsd' % TMUX_MAX_VERSION == get_version(), (
54+
"Is the latest supported version with -openbsd appended"
55+
)
4956

5057

5158
def test_get_version_too_low(monkeypatch):

0 commit comments

Comments
 (0)