Skip to content

Commit 311a223

Browse files
committed
Fixed error with awaitable tests
1 parent 0855a56 commit 311a223

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

tests/test_asyncio/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import random
22
from contextlib import asynccontextmanager as _asynccontextmanager
33
from typing import Union
4-
from unittest.mock import AsyncMock
4+
from unittest.mock import Mock
55

66
import pytest
77
import pytest_asyncio
@@ -222,13 +222,13 @@ async def mock_cluster_resp_slaves(create_redis, **kwargs):
222222

223223
@pytest_asyncio.fixture()
224224
def mock_connection() -> Connection:
225-
mock_connection = AsyncMock(spec=Connection)
225+
mock_connection = Mock(spec=Connection)
226226
return mock_connection
227227

228228

229229
@pytest_asyncio.fixture()
230230
def mock_pool() -> ConnectionPool:
231-
mock_pool = AsyncMock(spec=ConnectionPool)
231+
mock_pool = Mock(spec=ConnectionPool)
232232
return mock_pool
233233

234234

tests/test_asyncio/test_connection.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import sys
44
import types
55
from errno import ECONNREFUSED
6-
from unittest.mock import patch
6+
from unittest.mock import patch, AsyncMock
77

88
import pytest
99
import redis
@@ -317,7 +317,6 @@ async def get_redis_connection():
317317

318318

319319
@pytest.mark.onlynoncluster
320-
@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python > 3.8")
321320
async def test_client_do_not_retry_write_on_read_failure(mock_connection, mock_pool):
322321
mock_connection.send_command.return_value = True
323322
mock_connection.read_response.side_effect = [
@@ -327,7 +326,7 @@ async def test_client_do_not_retry_write_on_read_failure(mock_connection, mock_p
327326
]
328327
mock_connection.retry = Retry(ExponentialBackoff(), 3)
329328
mock_connection.retry_on_error = (ConnectionError,)
330-
mock_pool.get_connection.return_value = mock_connection
329+
mock_pool.get_connection = AsyncMock(return_value=mock_connection)
331330
mock_pool.connection_kwargs = {}
332331

333332
r = Redis(
@@ -343,7 +342,6 @@ async def test_client_do_not_retry_write_on_read_failure(mock_connection, mock_p
343342

344343

345344
@pytest.mark.onlynoncluster
346-
@pytest.mark.skipif(sys.version_info < (3, 9), reason="requires python > 3.8")
347345
async def test_pipeline_immediate_do_not_retry_write_on_read_failure(
348346
mock_connection, mock_pool
349347
):
@@ -355,7 +353,7 @@ async def test_pipeline_immediate_do_not_retry_write_on_read_failure(
355353
]
356354
mock_connection.retry = Retry(ExponentialBackoff(), 3)
357355
mock_connection.retry_on_error = (ConnectionError,)
358-
mock_pool.get_connection.return_value = mock_connection
356+
mock_pool.get_connection = AsyncMock(return_value=mock_connection)
359357
mock_pool.connection_kwargs = {}
360358

361359
r = Redis(

0 commit comments

Comments
 (0)