Skip to content

Fix error when using is_version with lettered tmux version #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions libtmux/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import os
import re
import subprocess
from distutils.version import StrictVersion
from distutils.version import StrictVersion, LooseVersion

from . import exc
from ._compat import console_to_str
Expand Down Expand Up @@ -387,7 +387,7 @@ def is_version(version):

installed_version = proc.stdout[0].split('tmux ')[1]

return StrictVersion(installed_version) == StrictVersion(version)
return LooseVersion(installed_version) == LooseVersion(version)


def has_required_tmux_version(version=None):
Expand Down
6 changes: 5 additions & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest

from libtmux.common import has_required_tmux_version, which, session_check_name
from libtmux.common import has_required_tmux_version, which, session_check_name, is_version
from libtmux.exc import LibTmuxException, BadSessionName

version_regex = re.compile(r'[0-9]\.[0-9]')
Expand All @@ -32,6 +32,10 @@ def test_ignores_letter_versions():
result = has_required_tmux_version('1.8a')
assert result == r'1.8'

# Should not throw
assert type(is_version('1.8')) is bool
assert type(is_version('1.8a')) is bool
assert type(is_version('1.9a')) is bool

def test_error_version_less_1_7():
with pytest.raises(LibTmuxException) as excinfo:
Expand Down