2020from redis .utils import HIREDIS_AVAILABLE
2121from tests .conftest import get_protocol_version , skip_if_server_version_lt
2222
23- from .compat import aclosing , create_task , mock
23+ from .compat import aclosing
2424
2525
2626def with_timeout (t ):
@@ -733,7 +733,7 @@ async def loop_step():
733733 await messages .put (message )
734734 break
735735
736- task = asyncio .get_running_loop (). create_task (loop ())
736+ task = asyncio .create_task (loop ())
737737 # get the initial connect message
738738 async with async_timeout (1 ):
739739 message = await messages .get ()
@@ -782,7 +782,7 @@ def callback(message):
782782 messages = asyncio .Queue ()
783783 p = pubsub
784784 await self ._subscribe (p , foo = callback )
785- task = asyncio .get_running_loop (). create_task (p .run ())
785+ task = asyncio .create_task (p .run ())
786786 await r .publish ("foo" , "bar" )
787787 message = await messages .get ()
788788 task .cancel ()
@@ -805,8 +805,8 @@ def exception_handler_callback(e, pubsub) -> None:
805805 exceptions = asyncio .Queue ()
806806 p = pubsub
807807 await self ._subscribe (p , foo = lambda x : None )
808- with mock . patch .object (p , "get_message" , side_effect = Exception ("error" )):
809- task = asyncio .get_running_loop (). create_task (
808+ with patch .object (p , "get_message" , side_effect = Exception ("error" )):
809+ task = asyncio .create_task (
810810 p .run (exception_handler = exception_handler_callback )
811811 )
812812 e = await exceptions .get ()
@@ -823,7 +823,7 @@ def callback(message):
823823
824824 messages = asyncio .Queue ()
825825 p = pubsub
826- task = asyncio .get_running_loop (). create_task (p .run ())
826+ task = asyncio .create_task (p .run ())
827827 # wait until loop gets settled. Add a subscription
828828 await asyncio .sleep (0.1 )
829829 await p .subscribe (foo = callback )
@@ -867,7 +867,7 @@ async def mysetup(self, r, method):
867867 else :
868868 self .get_message = self .loop_step_listen
869869
870- self .task = create_task (self .loop ())
870+ self .task = asyncio . create_task (self .loop ())
871871 # get the initial connect message
872872 message = await self .messages .get ()
873873 assert message == {
@@ -903,7 +903,7 @@ async def test_reconnect_socket_error(self, r: redis.Redis, method):
903903 async with self .cond :
904904 assert self .state == 0
905905 self .state = 1
906- with mock . patch .object (self .pubsub .connection , "_parser" ) as m :
906+ with patch .object (self .pubsub .connection , "_parser" ) as m :
907907 m .read_response .side_effect = socket .error
908908 m .can_read_destructive .side_effect = socket .error
909909 # wait until task noticies the disconnect until we
0 commit comments