@@ -2775,7 +2775,7 @@ def test__unregister_task_not_registered(self):
2775
2775
self .assertEqual (asyncio .all_tasks (loop ), set ())
2776
2776
2777
2777
2778
- class PyIntrospectionTests (unittest .TestCase , BaseTaskIntrospectionTests ):
2778
+ class PyIntrospectionTests (test_utils .TestCase , BaseTaskIntrospectionTests ):
2779
2779
_register_task = staticmethod (tasks ._py_register_task )
2780
2780
_unregister_task = staticmethod (tasks ._py_unregister_task )
2781
2781
_enter_task = staticmethod (tasks ._py_enter_task )
@@ -2784,7 +2784,7 @@ class PyIntrospectionTests(unittest.TestCase, BaseTaskIntrospectionTests):
2784
2784
2785
2785
@unittest .skipUnless (hasattr (tasks , '_c_register_task' ),
2786
2786
'requires the C _asyncio module' )
2787
- class CIntrospectionTests (unittest .TestCase , BaseTaskIntrospectionTests ):
2787
+ class CIntrospectionTests (test_utils .TestCase , BaseTaskIntrospectionTests ):
2788
2788
if hasattr (tasks , '_c_register_task' ):
2789
2789
_register_task = staticmethod (tasks ._c_register_task )
2790
2790
_unregister_task = staticmethod (tasks ._c_unregister_task )
@@ -2799,12 +2799,7 @@ class BaseCurrentLoopTests:
2799
2799
def setUp (self ):
2800
2800
super ().setUp ()
2801
2801
self .loop = asyncio .new_event_loop ()
2802
- asyncio .set_event_loop (self .loop )
2803
-
2804
- def tearDown (self ):
2805
- self .loop .close ()
2806
- asyncio .set_event_loop (None )
2807
- super ().tearDown ()
2802
+ self .set_event_loop (self .loop )
2808
2803
2809
2804
def new_task (self , coro ):
2810
2805
raise NotImplementedError
@@ -2828,15 +2823,15 @@ async def coro():
2828
2823
self .assertIsNone (asyncio .current_task (loop = self .loop ))
2829
2824
2830
2825
2831
- class PyCurrentLoopTests (BaseCurrentLoopTests , unittest .TestCase ):
2826
+ class PyCurrentLoopTests (BaseCurrentLoopTests , test_utils .TestCase ):
2832
2827
2833
2828
def new_task (self , coro ):
2834
2829
return tasks ._PyTask (coro , loop = self .loop )
2835
2830
2836
2831
2837
2832
@unittest .skipUnless (hasattr (tasks , '_CTask' ),
2838
2833
'requires the C _asyncio module' )
2839
- class CCurrentLoopTests (BaseCurrentLoopTests , unittest .TestCase ):
2834
+ class CCurrentLoopTests (BaseCurrentLoopTests , test_utils .TestCase ):
2840
2835
2841
2836
def new_task (self , coro ):
2842
2837
return getattr (tasks , '_CTask' )(coro , loop = self .loop )
@@ -3245,7 +3240,7 @@ class SleepTests(test_utils.TestCase):
3245
3240
def setUp (self ):
3246
3241
super ().setUp ()
3247
3242
self .loop = asyncio .new_event_loop ()
3248
- asyncio .set_event_loop (None )
3243
+ self .set_event_loop (self . loop )
3249
3244
3250
3245
def tearDown (self ):
3251
3246
self .loop .close ()
@@ -3279,7 +3274,7 @@ class WaitTests(test_utils.TestCase):
3279
3274
def setUp (self ):
3280
3275
super ().setUp ()
3281
3276
self .loop = asyncio .new_event_loop ()
3282
- asyncio .set_event_loop (None )
3277
+ self .set_event_loop (self . loop )
3283
3278
3284
3279
def tearDown (self ):
3285
3280
self .loop .close ()
@@ -3306,7 +3301,7 @@ class CompatibilityTests(test_utils.TestCase):
3306
3301
def setUp (self ):
3307
3302
super ().setUp ()
3308
3303
self .loop = asyncio .new_event_loop ()
3309
- asyncio .set_event_loop (None )
3304
+ self .set_event_loop (self . loop )
3310
3305
3311
3306
def tearDown (self ):
3312
3307
self .loop .close ()
0 commit comments