Skip to content

Commit 7c9fd86

Browse files
committed
Convert hack into class
1 parent 93da5b1 commit 7c9fd86

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/test_asyncio/conftest.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
from .compat import mock
1919

2020

21+
class AwaitableMock(AsyncMock):
22+
def __await__(self):
23+
pass
24+
25+
2126
async def _get_info(redis_url):
2227
client = redis.Redis.from_url(redis_url)
2328
info = await client.info()
@@ -222,20 +227,15 @@ async def mock_cluster_resp_slaves(create_redis, **kwargs):
222227

223228
@pytest_asyncio.fixture()
224229
def mock_connection() -> Connection:
225-
mock_connection = AsyncMock(spec=Connection)
226-
mock_connection.__await__ = dummy_awaitable
230+
mock_connection = AwaitableMock(spec=Connection)
227231
return mock_connection
228232

229233

230234
@pytest_asyncio.fixture()
231235
def mock_pool() -> ConnectionPool:
232-
mock_pool = AsyncMock(spec=ConnectionPool)
233-
mock_pool.__await__ = dummy_awaitable
236+
mock_pool = AwaitableMock(spec=ConnectionPool)
234237
return mock_pool
235238

236-
def dummy_awaitable():
237-
pass
238-
239239

240240
@pytest_asyncio.fixture()
241241
async def credential_provider(request) -> CredentialProvider:

0 commit comments

Comments
 (0)