@@ -240,30 +240,23 @@ def test_set_debug(self):
240
240
self .loop .set_debug (False )
241
241
self .assertFalse (self .loop .get_debug ())
242
242
243
- @mock .patch ('asyncio.base_events.time' )
244
243
@mock .patch ('asyncio.base_events.logger' )
245
- def test__run_once_logging (self , m_logger , m_time ):
246
- # Log to INFO level if timeout > 1.0 sec.
247
- idx = - 1
248
- data = [10.0 , 10.0 , 12.0 , 13.0 ]
249
-
250
- def monotonic ():
251
- nonlocal data , idx
252
- idx += 1
253
- return data [idx ]
244
+ def test__run_once_logging (self , m_logger ):
245
+ def slow_select (timeout ):
246
+ time .sleep (1.0 )
247
+ return []
254
248
255
- m_time .monotonic = monotonic
256
-
257
- self .loop ._scheduled .append (
258
- asyncio .TimerHandle (11.0 , lambda : True , (), self .loop ))
249
+ # Log to INFO level if timeout > 1.0 sec.
250
+ self .loop ._selector .select = slow_select
259
251
self .loop ._process_events = mock .Mock ()
260
252
self .loop ._run_once ()
261
253
self .assertEqual (logging .INFO , m_logger .log .call_args [0 ][0 ])
262
254
263
- idx = - 1
264
- data = [10.0 , 10.0 , 10.3 , 13.0 ]
265
- self .loop ._scheduled = [asyncio .TimerHandle (11.0 , lambda : True , (),
266
- self .loop )]
255
+ def fast_select (timeout ):
256
+ time .sleep (0.001 )
257
+ return []
258
+
259
+ self .loop ._selector .select = fast_select
267
260
self .loop ._run_once ()
268
261
self .assertEqual (logging .DEBUG , m_logger .log .call_args [0 ][0 ])
269
262
0 commit comments