Skip to content

Commit 27237ff

Browse files
committed
Better fixture use
1 parent ccaecd9 commit 27237ff

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

tests/test_async_cluster_mode.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,15 @@ async def get(key):
105105

106106

107107
@pytest.fixture
108-
def mock_async_redis_cluster():
108+
async def mock_async_redis_cluster(redis_url):
109109
"""Fixture to create a mock Async Redis cluster client."""
110-
return MockAsyncRedisCluster()
110+
# Use from_url to create the Redis client
111+
client = AsyncRedis.from_url(redis_url)
112+
# Create a mock that inherits from the real client
113+
mock = MockAsyncRedisCluster()
114+
# Copy connection attributes from the real client
115+
mock.connection_pool = client.connection_pool
116+
return mock
111117

112118

113119
@pytest.fixture

tests/test_cluster_mode.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ def get(key):
7676

7777

7878
@pytest.fixture
79-
def mock_redis_cluster():
79+
def mock_redis_cluster(redis_url):
8080
"""Fixture to create a mock Redis cluster client."""
81-
return MockRedisCluster()
81+
# Use from_url to create the Redis client
82+
client = Redis.from_url(redis_url)
83+
# Create a mock that inherits from the real client
84+
mock = MockRedisCluster()
85+
# Copy connection attributes from the real client
86+
mock.connection_pool = client.connection_pool
87+
return mock
8288

8389

8490
@pytest.fixture

0 commit comments

Comments
 (0)