Skip to content

Commit

Permalink
Removing packaging dependency (#1626)
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim authored Oct 19, 2021
1 parent 3981484 commit 2d18a05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions redis/connection.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from packaging.version import Version
from distutils.version import LooseVersion
from itertools import chain
from time import time
from queue import LifoQueue, Empty, Full
Expand Down Expand Up @@ -54,13 +54,13 @@
if HIREDIS_AVAILABLE:
import hiredis

hiredis_version = Version(hiredis.__version__)
hiredis_version = LooseVersion(hiredis.__version__)
HIREDIS_SUPPORTS_CALLABLE_ERRORS = \
hiredis_version >= Version('0.1.3')
hiredis_version >= LooseVersion('0.1.3')
HIREDIS_SUPPORTS_BYTE_BUFFER = \
hiredis_version >= Version('0.1.4')
hiredis_version >= LooseVersion('0.1.4')
HIREDIS_SUPPORTS_ENCODING_ERRORS = \
hiredis_version >= Version('1.0.0')
hiredis_version >= LooseVersion('1.0.0')

if not HIREDIS_SUPPORTS_BYTE_BUFFER:
msg = ("redis-py works best with hiredis >= 0.1.4. You're running "
Expand Down
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
import random
import redis
from packaging.version import Version
from distutils.version import LooseVersion
from redis.connection import parse_url
from unittest.mock import Mock
from urllib.parse import urlparse
Expand Down Expand Up @@ -38,15 +38,15 @@ def pytest_sessionstart(session):

def skip_if_server_version_lt(min_version):
redis_version = REDIS_INFO["version"]
check = Version(redis_version) < Version(min_version)
check = LooseVersion(redis_version) < LooseVersion(min_version)
return pytest.mark.skipif(
check,
reason="Redis version required >= {}".format(min_version))


def skip_if_server_version_gte(min_version):
redis_version = REDIS_INFO["version"]
check = Version(redis_version) >= Version(min_version)
check = LooseVersion(redis_version) >= LooseVersion(min_version)
return pytest.mark.skipif(
check,
reason="Redis version required < {}".format(min_version))
Expand Down Expand Up @@ -183,7 +183,7 @@ def wait_for_command(client, monitor, command):
# if we find a command with our key before the command we're waiting
# for, something went wrong
redis_version = REDIS_INFO["version"]
if Version(redis_version) >= Version('5.0.0'):
if LooseVersion(redis_version) >= LooseVersion('5.0.0'):
id_str = str(client.client_id())
else:
id_str = '%08x' % random.randrange(2**32)
Expand Down

0 comments on commit 2d18a05

Please sign in to comment.