11
11
from zigpy_znp .exceptions import CommandNotRecognized , InvalidCommandResponse
12
12
13
13
14
- async def test_callback_rsp (connected_znp , event_loop ):
14
+ async def test_callback_rsp (connected_znp ):
15
15
znp , znp_server = connected_znp
16
16
17
17
def send_responses ():
@@ -20,7 +20,7 @@ def send_responses():
20
20
c .AF .DataConfirm .Callback (Endpoint = 56 , TSN = 1 , Status = t .Status .SUCCESS )
21
21
)
22
22
23
- event_loop .call_soon (send_responses )
23
+ asyncio . get_running_loop () .call_soon (send_responses )
24
24
25
25
# The UART sometimes replies with a SRSP and an AREQ faster than
26
26
# we can register callbacks for both. This method is a workaround.
@@ -150,7 +150,7 @@ async def replier(req):
150
150
assert len (znp ._unhandled_command .mock_calls ) == 0
151
151
152
152
153
- async def test_callback_rsp_cleanup_concurrent (connected_znp , event_loop , mocker ):
153
+ async def test_callback_rsp_cleanup_concurrent (connected_znp , mocker ):
154
154
znp , znp_server = connected_znp
155
155
156
156
mocker .spy (znp , "_unhandled_command" )
@@ -163,7 +163,7 @@ def send_responses():
163
163
znp_server .send (c .SYS .OSALTimerExpired .Callback (Id = 0xAB ))
164
164
znp_server .send (c .SYS .OSALTimerExpired .Callback (Id = 0xCD ))
165
165
166
- event_loop .call_soon (send_responses )
166
+ asyncio . get_running_loop () .call_soon (send_responses )
167
167
168
168
callback_rsp = await znp .request_callback_rsp (
169
169
request = c .UTIL .TimeAlive .Req (),
@@ -183,7 +183,7 @@ def send_responses():
183
183
]
184
184
185
185
186
- async def test_znp_request_kwargs (connected_znp , event_loop ):
186
+ async def test_znp_request_kwargs (connected_znp ):
187
187
znp , znp_server = connected_znp
188
188
189
189
# Invalid format
@@ -196,7 +196,7 @@ async def test_znp_request_kwargs(connected_znp, event_loop):
196
196
197
197
# Valid format, valid name
198
198
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 )
200
200
assert (
201
201
await znp .request (c .SYS .Ping .Req (), RspCapabilities = t .MTCapabilities .SYS )
202
202
) == ping_rsp
@@ -227,7 +227,7 @@ async def test_znp_request_kwargs(connected_znp, event_loop):
227
227
)
228
228
229
229
230
- async def test_znp_request_not_recognized (connected_znp , event_loop ):
230
+ async def test_znp_request_not_recognized (connected_znp ):
231
231
znp , _ = connected_znp
232
232
233
233
# 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):
237
237
)
238
238
239
239
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 ())
241
241
await znp .request (request )
242
242
243
243
244
- async def test_znp_request_wrong_params (connected_znp , event_loop ):
244
+ async def test_znp_request_wrong_params (connected_znp ):
245
245
znp , _ = connected_znp
246
246
247
247
# 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):
250
250
251
251
# An error is raised when a response with bad params is received
252
252
with pytest .raises (InvalidCommandResponse ):
253
- event_loop .call_soon (
253
+ asyncio . get_running_loop () .call_soon (
254
254
znp .frame_received ,
255
255
c .SYS .Ping .Rsp (Capabilities = t .MTCapabilities .SYS ).to_frame (),
256
256
)
257
257
await znp .request (c .SYS .Ping .Req (), RspCapabilities = t .MTCapabilities .APP )
258
258
259
259
260
- async def test_znp_sreq_srsp (connected_znp , event_loop ):
260
+ async def test_znp_sreq_srsp (connected_znp ):
261
261
znp , _ = connected_znp
262
262
263
263
# 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):
267
267
268
268
# This will work
269
269
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 ())
271
271
272
272
await znp .request (c .SYS .Ping .Req ())
273
273
0 commit comments