@@ -235,6 +235,11 @@ def cb():
235
235
self .assertIsInstance (h , asyncio .Handle )
236
236
self .assertIn (h , self .loop ._ready )
237
237
238
+ def test_call_soon_non_callable (self ):
239
+ self .loop .set_debug (True )
240
+ with self .assertRaisesRegex (TypeError , 'a callable object' ):
241
+ self .loop .call_soon (1 )
242
+
238
243
def test_call_later (self ):
239
244
def cb ():
240
245
pass
@@ -341,47 +346,21 @@ def test_thread(loop, debug, create_loop=False):
341
346
# check disabled if debug mode is disabled
342
347
test_thread (self .loop , False , create_loop = True )
343
348
344
- def test_run_once_in_executor_handle (self ):
345
- def cb ():
346
- pass
347
-
348
- self .assertRaises (
349
- AssertionError , self .loop .run_in_executor ,
350
- None , asyncio .Handle (cb , (), self .loop ), ('' ,))
351
- self .assertRaises (
352
- AssertionError , self .loop .run_in_executor ,
353
- None , asyncio .TimerHandle (10 , cb , (), self .loop ))
354
-
355
- def test_run_once_in_executor_cancelled (self ):
356
- def cb ():
357
- pass
358
- h = asyncio .Handle (cb , (), self .loop )
359
- h .cancel ()
360
-
361
- with self .assertWarnsRegex (DeprecationWarning , "Passing Handle" ):
362
- f = self .loop .run_in_executor (None , h )
363
- self .assertIsInstance (f , asyncio .Future )
364
- self .assertTrue (f .done ())
365
- self .assertIsNone (f .result ())
366
-
367
349
def test_run_once_in_executor_plain (self ):
368
350
def cb ():
369
351
pass
370
- h = asyncio .Handle (cb , (), self .loop )
371
352
f = asyncio .Future (loop = self .loop )
372
353
executor = mock .Mock ()
373
354
executor .submit .return_value = f
374
355
375
356
self .loop .set_default_executor (executor )
376
357
377
- with self .assertWarnsRegex (DeprecationWarning , "Passing Handle" ):
378
- res = self .loop .run_in_executor (None , h )
358
+ res = self .loop .run_in_executor (None , cb )
379
359
self .assertIs (f , res )
380
360
381
361
executor = mock .Mock ()
382
362
executor .submit .return_value = f
383
- with self .assertWarnsRegex (DeprecationWarning , "Passing Handle" ):
384
- res = self .loop .run_in_executor (executor , h )
363
+ res = self .loop .run_in_executor (executor , cb )
385
364
self .assertIs (f , res )
386
365
self .assertTrue (executor .submit .called )
387
366
0 commit comments