1111from zigpy_znp .exceptions import CommandNotRecognized , InvalidCommandResponse
1212
1313
14- async def test_callback_rsp (connected_znp , event_loop ):
14+ async def test_callback_rsp (connected_znp ):
1515 znp , znp_server = connected_znp
1616
1717 def send_responses ():
@@ -20,7 +20,7 @@ def send_responses():
2020 c .AF .DataConfirm .Callback (Endpoint = 56 , TSN = 1 , Status = t .Status .SUCCESS )
2121 )
2222
23- event_loop .call_soon (send_responses )
23+ asyncio . get_running_loop () .call_soon (send_responses )
2424
2525 # The UART sometimes replies with a SRSP and an AREQ faster than
2626 # we can register callbacks for both. This method is a workaround.
@@ -150,7 +150,7 @@ async def replier(req):
150150 assert len (znp ._unhandled_command .mock_calls ) == 0
151151
152152
153- async def test_callback_rsp_cleanup_concurrent (connected_znp , event_loop , mocker ):
153+ async def test_callback_rsp_cleanup_concurrent (connected_znp , mocker ):
154154 znp , znp_server = connected_znp
155155
156156 mocker .spy (znp , "_unhandled_command" )
@@ -163,7 +163,7 @@ def send_responses():
163163 znp_server .send (c .SYS .OSALTimerExpired .Callback (Id = 0xAB ))
164164 znp_server .send (c .SYS .OSALTimerExpired .Callback (Id = 0xCD ))
165165
166- event_loop .call_soon (send_responses )
166+ asyncio . get_running_loop () .call_soon (send_responses )
167167
168168 callback_rsp = await znp .request_callback_rsp (
169169 request = c .UTIL .TimeAlive .Req (),
@@ -183,7 +183,7 @@ def send_responses():
183183 ]
184184
185185
186- async def test_znp_request_kwargs (connected_znp , event_loop ):
186+ async def test_znp_request_kwargs (connected_znp ):
187187 znp , znp_server = connected_znp
188188
189189 # Invalid format
@@ -196,7 +196,7 @@ async def test_znp_request_kwargs(connected_znp, event_loop):
196196
197197 # Valid format, valid name
198198 ping_rsp = c .SYS .Ping .Rsp (Capabilities = t .MTCapabilities .SYS )
199- event_loop .call_soon (znp_server .send , ping_rsp )
199+ asyncio . get_running_loop () .call_soon (znp_server .send , ping_rsp )
200200 assert (
201201 await znp .request (c .SYS .Ping .Req (), RspCapabilities = t .MTCapabilities .SYS )
202202 ) == ping_rsp
@@ -227,7 +227,7 @@ async def test_znp_request_kwargs(connected_znp, event_loop):
227227 )
228228
229229
230- async def test_znp_request_not_recognized (connected_znp , event_loop ):
230+ async def test_znp_request_not_recognized (connected_znp ):
231231 znp , _ = connected_znp
232232
233233 # An error is raise when a bad request is sent
@@ -237,11 +237,11 @@ async def test_znp_request_not_recognized(connected_znp, event_loop):
237237 )
238238
239239 with pytest .raises (CommandNotRecognized ):
240- event_loop .call_soon (znp .frame_received , unknown_rsp .to_frame ())
240+ asyncio . get_running_loop () .call_soon (znp .frame_received , unknown_rsp .to_frame ())
241241 await znp .request (request )
242242
243243
244- async def test_znp_request_wrong_params (connected_znp , event_loop ):
244+ async def test_znp_request_wrong_params (connected_znp ):
245245 znp , _ = connected_znp
246246
247247 # You cannot specify response kwargs for responses with no response
@@ -250,14 +250,14 @@ async def test_znp_request_wrong_params(connected_znp, event_loop):
250250
251251 # An error is raised when a response with bad params is received
252252 with pytest .raises (InvalidCommandResponse ):
253- event_loop .call_soon (
253+ asyncio . get_running_loop () .call_soon (
254254 znp .frame_received ,
255255 c .SYS .Ping .Rsp (Capabilities = t .MTCapabilities .SYS ).to_frame (),
256256 )
257257 await znp .request (c .SYS .Ping .Req (), RspCapabilities = t .MTCapabilities .APP )
258258
259259
260- async def test_znp_sreq_srsp (connected_znp , event_loop ):
260+ async def test_znp_sreq_srsp (connected_znp ):
261261 znp , _ = connected_znp
262262
263263 # Each SREQ must have a corresponding SRSP, so this will fail
@@ -267,7 +267,7 @@ async def test_znp_sreq_srsp(connected_znp, event_loop):
267267
268268 # This will work
269269 ping_rsp = c .SYS .Ping .Rsp (Capabilities = t .MTCapabilities .SYS )
270- event_loop .call_soon (znp .frame_received , ping_rsp .to_frame ())
270+ asyncio . get_running_loop () .call_soon (znp .frame_received , ping_rsp .to_frame ())
271271
272272 await znp .request (c .SYS .Ping .Req ())
273273
0 commit comments