diff --git a/dev_requirements.txt b/dev_requirements.txt index f201098a14..43c88a08eb 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -2,8 +2,6 @@ build build==1.2.2.post1 ; platform_python_implementation == "PyPy" click==8.0.4 invoke==2.2.0 -mock -mock==5.1.0 ; platform_python_implementation == "PyPy" packaging>=20.4 packaging==24.2 ; platform_python_implementation == "PyPy" diff --git a/tests/test_asyncio/test_command_policies.py b/tests/test_asyncio/test_command_policies.py index 7a52f256c9..dadc096e9e 100644 --- a/tests/test_asyncio/test_command_policies.py +++ b/tests/test_asyncio/test_command_policies.py @@ -1,7 +1,7 @@ import random +from unittest.mock import patch import pytest -from mock import patch from redis import ResponseError from redis._parsers.commands import CommandPolicies, RequestPolicy, ResponsePolicy diff --git a/tests/test_asyncio/test_credentials.py b/tests/test_asyncio/test_credentials.py index b4824be469..bd2dc10413 100644 --- a/tests/test_asyncio/test_credentials.py +++ b/tests/test_asyncio/test_credentials.py @@ -4,11 +4,11 @@ from asyncio import Lock as AsyncLock from asyncio import sleep as async_sleep from typing import Optional, Tuple, Union +from unittest.mock import AsyncMock, call import pytest import pytest_asyncio import redis -from mock.mock import Mock, call from redis import AuthenticationError, DataError, RedisError, ResponseError from redis.asyncio import Connection, ConnectionPool, Redis from redis.asyncio.retry import Retry @@ -340,10 +340,10 @@ class TestStreamingCredentialProvider: indirect=True, ) async def test_async_re_auth_all_connections(self, credential_provider): - mock_connection = Mock(spec=Connection) + mock_connection = AsyncMock(spec=Connection) mock_connection.retry = Retry(NoBackoff(), 0) - mock_another_connection = Mock(spec=Connection) - mock_pool = Mock(spec=ConnectionPool) + mock_another_connection = AsyncMock(spec=Connection) + mock_pool = AsyncMock(spec=ConnectionPool) mock_pool.connection_kwargs = { "credential_provider": credential_provider, } @@ -391,16 +391,16 @@ async def re_auth_callback(token): indirect=True, ) async def test_async_re_auth_partial_connections(self, credential_provider): - mock_connection = Mock(spec=Connection) + mock_connection = AsyncMock(spec=Connection) mock_connection.retry = Retry(NoBackoff(), 3) - mock_another_connection = Mock(spec=Connection) + mock_another_connection = AsyncMock(spec=Connection) mock_another_connection.retry = Retry(NoBackoff(), 3) - mock_failed_connection = Mock(spec=Connection) + mock_failed_connection = AsyncMock(spec=Connection) mock_failed_connection.read_response.side_effect = ConnectionError( "Failed auth" ) mock_failed_connection.retry = Retry(NoBackoff(), 3) - mock_pool = Mock(spec=ConnectionPool) + mock_pool = AsyncMock(spec=ConnectionPool) mock_pool.connection_kwargs = { "credential_provider": credential_provider, } @@ -454,14 +454,14 @@ async def re_auth_callback(token): indirect=True, ) async def test_re_auth_pub_sub_in_resp3(self, credential_provider): - mock_pubsub_connection = Mock(spec=Connection) + mock_pubsub_connection = AsyncMock(spec=Connection) mock_pubsub_connection.get_protocol.return_value = 3 mock_pubsub_connection.credential_provider = credential_provider mock_pubsub_connection.retry = Retry(NoBackoff(), 3) - mock_another_connection = Mock(spec=Connection) + mock_another_connection = AsyncMock(spec=Connection) mock_another_connection.retry = Retry(NoBackoff(), 3) - mock_pool = Mock(spec=ConnectionPool) + mock_pool = AsyncMock(spec=ConnectionPool) mock_pool.connection_kwargs = { "credential_provider": credential_provider, } @@ -516,14 +516,14 @@ async def re_auth_callback(token): indirect=True, ) async def test_do_not_re_auth_pub_sub_in_resp2(self, credential_provider): - mock_pubsub_connection = Mock(spec=Connection) + mock_pubsub_connection = AsyncMock(spec=Connection) mock_pubsub_connection.get_protocol.return_value = 2 mock_pubsub_connection.credential_provider = credential_provider mock_pubsub_connection.retry = Retry(NoBackoff(), 3) - mock_another_connection = Mock(spec=Connection) + mock_another_connection = AsyncMock(spec=Connection) mock_another_connection.retry = Retry(NoBackoff(), 3) - mock_pool = Mock(spec=ConnectionPool) + mock_pool = AsyncMock(spec=ConnectionPool) mock_pool.connection_kwargs = { "credential_provider": credential_provider, } @@ -583,10 +583,10 @@ async def test_fails_on_token_renewal(self, credential_provider): RequestTokenErr, RequestTokenErr, ] - mock_connection = Mock(spec=Connection) + mock_connection = AsyncMock(spec=Connection) mock_connection.retry = Retry(NoBackoff(), 0) - mock_another_connection = Mock(spec=Connection) - mock_pool = Mock(spec=ConnectionPool) + mock_another_connection = AsyncMock(spec=Connection) + mock_pool = AsyncMock(spec=ConnectionPool) mock_pool.connection_kwargs = { "credential_provider": credential_provider, } diff --git a/tests/test_asyncio/test_multidb/test_healthcheck.py b/tests/test_asyncio/test_multidb/test_healthcheck.py index 5a08f21a68..49b69ddafe 100644 --- a/tests/test_asyncio/test_multidb/test_healthcheck.py +++ b/tests/test_asyncio/test_multidb/test_healthcheck.py @@ -1,5 +1,6 @@ +from unittest.mock import AsyncMock, Mock + import pytest -from mock.mock import AsyncMock, Mock from redis.asyncio.multidb.database import Database from redis.asyncio.multidb.healthcheck import ( diff --git a/tests/test_credentials.py b/tests/test_credentials.py index 29140b9e05..ef20fdbbdc 100644 --- a/tests/test_credentials.py +++ b/tests/test_credentials.py @@ -4,10 +4,10 @@ import threading from time import sleep from typing import Optional, Tuple, Union +from unittest.mock import Mock, call import pytest import redis -from mock.mock import Mock, call from redis import AuthenticationError, DataError, Redis, ResponseError from redis.auth.err import RequestTokenErr from redis.backoff import NoBackoff