From: Colin Watson <cjwatson@debian.org>
Date: Thu, 10 Apr 2025 15:17:32 +0100
Subject: Adjust tests for redis-server < 7.2

Last-Update: 2025-04-10
---
 tests/test_asyncio/test_cluster.py  | 7 ++++++-
 tests/test_asyncio/test_commands.py | 7 ++++++-
 tests/test_cluster.py               | 7 ++++++-
 tests/test_commands.py              | 7 ++++++-
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/tests/test_asyncio/test_cluster.py b/tests/test_asyncio/test_cluster.py
index 25f487f..319e159 100644
--- a/tests/test_asyncio/test_cluster.py
+++ b/tests/test_asyncio/test_cluster.py
@@ -10,6 +10,7 @@ from urllib.parse import urlparse
 import pytest
 import pytest_asyncio
 from _pytest.fixtures import FixtureRequest
+from packaging.version import Version
 from redis._parsers import AsyncCommandsParser
 from redis.asyncio.cluster import ClusterNode, NodesManager, RedisCluster
 from redis.asyncio.connection import Connection, SSLConnection, async_timeout
@@ -41,6 +42,7 @@ from redis.exceptions import (
 )
 from redis.utils import str_if_bytes
 from tests.conftest import (
+    REDIS_INFO,
     assert_resp_response,
     is_resp2_connection,
     skip_if_redis_enterprise,
@@ -2415,7 +2417,10 @@ class TestClusterRedisCommands:
             await user_client.hset("{cache}:0", "hkey", "hval")
 
         assert isinstance(await r.acl_log(target_nodes=node), list)
-        assert len(await r.acl_log(target_nodes=node)) == 3
+        if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+            assert len(await r.acl_log(target_nodes=node)) == 3
+        else:
+            assert len(await r.acl_log(target_nodes=node)) == 2
         assert len(await r.acl_log(count=1, target_nodes=node)) == 1
         assert isinstance((await r.acl_log(target_nodes=node))[0], dict)
         assert "client-info" in (await r.acl_log(count=1, target_nodes=node))[0]
diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py
index 9db7d20..cc7b9a6 100644
--- a/tests/test_asyncio/test_commands.py
+++ b/tests/test_asyncio/test_commands.py
@@ -12,6 +12,7 @@ from string import ascii_letters
 import pytest
 import pytest_asyncio
 import redis
+from packaging.version import Version
 from redis import exceptions
 from redis._parsers.helpers import (
     _RedisCallbacks,
@@ -24,6 +25,7 @@ from redis.commands.json.path import Path
 from redis.commands.search.field import TextField
 from redis.commands.search.query import Query
 from tests.conftest import (
+    REDIS_INFO,
     assert_resp_response,
     assert_resp_response_in,
     is_resp2_connection,
@@ -331,7 +333,10 @@ class TestRedisCommands:
             await user_client.hset("cache:0", "hkey", "hval")
 
         assert isinstance(await r.acl_log(), list)
-        assert len(await r.acl_log()) == 3
+        if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+            assert len(await r.acl_log()) == 3
+        else:
+            assert len(await r.acl_log()) == 2
         assert len(await r.acl_log(count=1)) == 1
         assert isinstance((await r.acl_log())[0], dict)
         expected = (await r.acl_log(count=1))[0]
diff --git a/tests/test_cluster.py b/tests/test_cluster.py
index 4883ba6..092388d 100644
--- a/tests/test_cluster.py
+++ b/tests/test_cluster.py
@@ -12,6 +12,7 @@ from unittest.mock import DEFAULT, Mock, call, patch
 
 import pytest
 import redis
+from packaging.version import Version
 from redis import Redis
 from redis._parsers import CommandsParser
 from redis.backoff import (
@@ -48,6 +49,7 @@ from redis.utils import str_if_bytes
 from tests.test_pubsub import wait_for_message
 
 from .conftest import (
+    REDIS_INFO,
     _get_client,
     assert_resp_response,
     is_resp2_connection,
@@ -2516,7 +2518,10 @@ class TestClusterRedisCommands:
             user_client.hset("{cache}:0", "hkey", "hval")
 
         assert isinstance(r.acl_log(target_nodes=node), list)
-        assert len(r.acl_log(target_nodes=node)) == 3
+        if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+            assert len(r.acl_log(target_nodes=node)) == 3
+        else:
+            assert len(r.acl_log(target_nodes=node)) == 2
         assert len(r.acl_log(count=1, target_nodes=node)) == 1
         assert isinstance(r.acl_log(target_nodes=node)[0], dict)
         assert "client-info" in r.acl_log(count=1, target_nodes=node)[0]
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 42530a4..5d4e7ec 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -10,6 +10,7 @@ from unittest.mock import patch
 
 import pytest
 import redis
+from packaging.version import Version
 from redis import exceptions
 from redis._parsers.helpers import (
     _RedisCallbacks,
@@ -24,6 +25,7 @@ from redis.commands.search.query import Query
 from tests.test_utils import redis_server_time
 
 from .conftest import (
+    REDIS_INFO,
     _get_client,
     assert_resp_response,
     assert_resp_response_in,
@@ -448,7 +450,10 @@ class TestRedisCommands:
             user_client.hset("cache:0", "hkey", "hval")
 
         assert isinstance(r.acl_log(), list)
-        assert len(r.acl_log()) == 3
+        if Version(REDIS_INFO.get("version", "0")) >= Version("7.2.0"):
+            assert len(r.acl_log()) == 3
+        else:
+            assert len(r.acl_log()) == 2
         assert len(r.acl_log(count=1)) == 1
         assert isinstance(r.acl_log()[0], dict)
         expected = r.acl_log(count=1)[0]
