@@ -2704,33 +2704,22 @@ def test_event_loop_policy(self):
27042704 def test_get_event_loop (self ):
27052705 policy = asyncio .DefaultEventLoopPolicy ()
27062706 self .assertIsNone (policy ._local ._loop )
2707- with self .assertWarns (DeprecationWarning ) as cm :
2708- loop = policy .get_event_loop ()
2709- self .assertEqual (cm .filename , __file__ )
2710- self .assertIsInstance (loop , asyncio .AbstractEventLoop )
27112707
2712- self .assertIs ( policy . _local . _loop , loop )
2713- self . assertIs ( loop , policy .get_event_loop () )
2714- loop . close ( )
2708+ with self .assertRaises ( RuntimeError ):
2709+ loop = policy .get_event_loop ()
2710+ self . assertIsNone ( policy . _local . _loop )
27152711
2716- def test_get_event_loop_calls_set_event_loop (self ):
2712+ def test_get_event_loop_does_not_call_set_event_loop (self ):
27172713 policy = asyncio .DefaultEventLoopPolicy ()
27182714
27192715 with mock .patch .object (
27202716 policy , "set_event_loop" ,
27212717 wraps = policy .set_event_loop ) as m_set_event_loop :
27222718
2723- with self .assertWarns ( DeprecationWarning ) as cm :
2719+ with self .assertRaises ( RuntimeError ) :
27242720 loop = policy .get_event_loop ()
2725- self .addCleanup (loop .close )
2726- self .assertEqual (cm .filename , __file__ )
27272721
2728- # policy._local._loop must be set through .set_event_loop()
2729- # (the unix DefaultEventLoopPolicy needs this call to attach
2730- # the child watcher correctly)
2731- m_set_event_loop .assert_called_with (loop )
2732-
2733- loop .close ()
2722+ m_set_event_loop .assert_not_called ()
27342723
27352724 def test_get_event_loop_after_set_none (self ):
27362725 policy = asyncio .DefaultEventLoopPolicy ()
@@ -2912,17 +2901,12 @@ def test_get_event_loop_returns_running_loop2(self):
29122901 loop = asyncio .new_event_loop ()
29132902 self .addCleanup (loop .close )
29142903
2915- with self .assertWarns (DeprecationWarning ) as cm :
2916- loop2 = asyncio .get_event_loop ()
2917- self .addCleanup (loop2 .close )
2918- self .assertEqual (cm .filename , __file__ )
2919- asyncio .set_event_loop (None )
29202904 with self .assertRaisesRegex (RuntimeError , 'no current' ):
29212905 asyncio .get_event_loop ()
29222906
2923- with self . assertRaisesRegex ( RuntimeError , 'no running' ):
2924- asyncio . get_running_loop ()
2925- self . assertIs ( asyncio ._get_running_loop (), None )
2907+ asyncio . set_event_loop ( None )
2908+ with self . assertRaisesRegex ( RuntimeError , 'no current' ):
2909+ asyncio .get_event_loop ( )
29262910
29272911 async def func ():
29282912 self .assertIs (asyncio .get_event_loop (), loop )
0 commit comments