Skip to content

Removing distutils from tests #1773

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 3 commits into from
Dec 8, 2021
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
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import random
import time
from distutils.version import LooseVersion
from unittest.mock import Mock
from urllib.parse import urlparse

import pytest
from packaging.version import Version

import redis
from redis.backoff import NoBackoff
Expand Down Expand Up @@ -117,13 +117,13 @@ def wait_for_cluster_creation(redis_url, cluster_nodes, timeout=20):

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


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


Expand Down Expand Up @@ -331,7 +331,7 @@ def wait_for_command(client, monitor, command, key=None):
if key is None:
# generate key
redis_version = REDIS_INFO["version"]
if LooseVersion(redis_version) >= LooseVersion("5.0.0"):
if Version(redis_version) >= Version("5.0.0"):
id_str = str(client.client_id())
else:
id_str = f"{random.randrange(2 ** 32):08x}"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ def teardown():
username,
enabled=True,
reset=True,
commands=["+get", "+set", "+select", "+cluster", "+command"],
commands=["+get", "+set", "+select", "+cluster", "+command", "+info"],
keys=["{cache}:*"],
nopass=True,
target_nodes="primaries",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ def test_client_kill_filter_by_user(self, r, request):
killuser,
enabled=True,
reset=True,
commands=["+get", "+set", "+select", "+cluster", "+command"],
commands=["+get", "+set", "+select", "+cluster", "+command", "+info"],
keys=["cache:*"],
nopass=True,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ def test_profile(client):
assert det["Iterators profile"]["Counter"] == 2.0
assert len(det["Iterators profile"]["Child iterators"]) == 2
assert det["Iterators profile"]["Type"] == "UNION"
assert det["Parsing time"] < 0.3
assert det["Parsing time"] < 0.5
assert len(res.docs) == 2 # check also the search result

# check using AggregateRequest
Expand All @@ -1431,7 +1431,7 @@ def test_profile(client):
res, det = client.ft().profile(req)
assert det["Iterators profile"]["Counter"] == 2.0
assert det["Iterators profile"]["Type"] == "WILDCARD"
assert det["Parsing time"] < 0.3
assert det["Parsing time"] < 0.5
assert len(res.rows) == 2 # check also the search result


Expand Down