Skip to content

Commit 5cf8e14

Browse files
committed
Added additional call count check for read_response
1 parent add64c5 commit 5cf8e14

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

tests/test_asyncio/conftest.py

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

66
import pytest
@@ -19,8 +19,9 @@
1919

2020

2121
class AwaitableMock(AsyncMock):
22-
def __await__(self):
23-
pass
22+
def __await__(self) -> Iterator[Any]:
23+
self.await_count += 1
24+
return iter([])
2425

2526

2627
async def _get_info(redis_url):

tests/test_asyncio/test_connection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ async def test_client_do_not_retry_write_on_read_failure(mock_connection, mock_p
337337

338338
# If read from socket fails, writes won't be executed.
339339
mock_connection.send_command.assert_called_once_with("SET", "key", "value")
340+
mock_connection.read_response.call_count = 3
340341

341342

342343
@pytest.mark.onlynoncluster
@@ -364,6 +365,7 @@ async def test_pipeline_immediate_do_not_retry_write_on_read_failure(
364365

365366
# If read from socket fails, writes won't be executed.
366367
mock_connection.send_command.assert_called_once_with("SET", "key", "value")
368+
mock_connection.read_response.call_count = 3
367369

368370

369371
async def test_close_is_aclose(request):

tests/test_connection.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ def test_client_do_not_retry_write_on_read_failure(mock_connection, mock_pool):
268268

269269
# If read from socket fails, writes won't be executed.
270270
mock_connection.send_command.assert_called_once_with("SET", "key", "value")
271+
mock_connection.read_response.call_count = 3
271272

272273

273274
@pytest.mark.onlynoncluster
@@ -291,6 +292,7 @@ def test_pipeline_immediate_do_not_retry_write_on_read_failure(
291292

292293
# If read from socket fails, writes won't be executed.
293294
mock_connection.send_command.assert_called_once_with("SET", "key", "value")
295+
mock_connection.read_response.call_count = 3
294296

295297

296298
@pytest.mark.skipif(sys.version_info == (3, 9), reason="Flacky test on Python 3.9")

0 commit comments

Comments
 (0)