@@ -267,12 +267,33 @@ async def run():
267
267
class PyEagerTaskFactoryLoopTests (EagerTaskFactoryLoopTests , test_utils .TestCase ):
268
268
Task = tasks ._PyTask
269
269
270
+ def setUp (self ):
271
+ self ._current_task = asyncio .current_task
272
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._py_current_task
273
+ return super ().setUp ()
274
+
275
+ def tearDown (self ):
276
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
277
+ return super ().tearDown ()
278
+
279
+
270
280
271
281
@unittest .skipUnless (hasattr (tasks , '_CTask' ),
272
282
'requires the C _asyncio module' )
273
283
class CEagerTaskFactoryLoopTests (EagerTaskFactoryLoopTests , test_utils .TestCase ):
274
284
Task = getattr (tasks , '_CTask' , None )
275
285
286
+ def setUp (self ):
287
+ self ._current_task = asyncio .current_task
288
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._c_current_task
289
+ return super ().setUp ()
290
+
291
+ def tearDown (self ):
292
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
293
+ return super ().tearDown ()
294
+
295
+
296
+ @unittest .skip ("skip" )
276
297
def test_issue105987 (self ):
277
298
code = """if 1:
278
299
from _asyncio import _swap_current_task
@@ -400,31 +421,83 @@ class BaseEagerTaskFactoryTests(BaseTaskCountingTests):
400
421
401
422
402
423
class NonEagerTests (BaseNonEagerTaskFactoryTests , test_utils .TestCase ):
403
- Task = asyncio .Task
424
+ Task = asyncio .tasks ._CTask
425
+
426
+ def setUp (self ):
427
+ self ._current_task = asyncio .current_task
428
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._c_current_task
429
+ return super ().setUp ()
404
430
431
+ def tearDown (self ):
432
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
433
+ return super ().tearDown ()
405
434
406
435
class EagerTests (BaseEagerTaskFactoryTests , test_utils .TestCase ):
407
- Task = asyncio .Task
436
+ Task = asyncio .tasks ._CTask
437
+
438
+ def setUp (self ):
439
+ self ._current_task = asyncio .current_task
440
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._c_current_task
441
+ return super ().setUp ()
442
+
443
+ def tearDown (self ):
444
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
445
+ return super ().tearDown ()
408
446
409
447
410
448
class NonEagerPyTaskTests (BaseNonEagerTaskFactoryTests , test_utils .TestCase ):
411
449
Task = tasks ._PyTask
412
450
451
+ def setUp (self ):
452
+ self ._current_task = asyncio .current_task
453
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._py_current_task
454
+ return super ().setUp ()
455
+
456
+ def tearDown (self ):
457
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
458
+ return super ().tearDown ()
459
+
413
460
414
461
class EagerPyTaskTests (BaseEagerTaskFactoryTests , test_utils .TestCase ):
415
462
Task = tasks ._PyTask
416
463
464
+ def setUp (self ):
465
+ self ._current_task = asyncio .current_task
466
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._py_current_task
467
+ return super ().setUp ()
468
+
469
+ def tearDown (self ):
470
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
471
+ return super ().tearDown ()
417
472
418
473
@unittest .skipUnless (hasattr (tasks , '_CTask' ),
419
474
'requires the C _asyncio module' )
420
475
class NonEagerCTaskTests (BaseNonEagerTaskFactoryTests , test_utils .TestCase ):
421
476
Task = getattr (tasks , '_CTask' , None )
422
477
478
+ def setUp (self ):
479
+ self ._current_task = asyncio .current_task
480
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._c_current_task
481
+ return super ().setUp ()
482
+
483
+ def tearDown (self ):
484
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
485
+ return super ().tearDown ()
486
+
423
487
424
488
@unittest .skipUnless (hasattr (tasks , '_CTask' ),
425
489
'requires the C _asyncio module' )
426
490
class EagerCTaskTests (BaseEagerTaskFactoryTests , test_utils .TestCase ):
427
491
Task = getattr (tasks , '_CTask' , None )
428
492
493
+ def setUp (self ):
494
+ self ._current_task = asyncio .current_task
495
+ asyncio .current_task = asyncio .tasks .current_task = asyncio .tasks ._c_current_task
496
+ return super ().setUp ()
497
+
498
+ def tearDown (self ):
499
+ asyncio .current_task = asyncio .tasks .current_task = self ._current_task
500
+ return super ().tearDown ()
501
+
429
502
if __name__ == '__main__' :
430
503
unittest .main ()
0 commit comments