@@ -2709,15 +2709,11 @@ def get_event_loop(self):
27092709 asyncio .set_event_loop_policy (Policy ())
27102710 loop = asyncio .new_event_loop ()
27112711
2712- with self .assertWarns (DeprecationWarning ) as cm :
2713- with self .assertRaises (TestError ):
2714- asyncio .get_event_loop ()
2715- self .assertEqual (cm .filename , __file__ )
2712+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2713+ asyncio .get_event_loop ()
27162714 asyncio .set_event_loop (None )
2717- with self .assertWarns (DeprecationWarning ) as cm :
2718- with self .assertRaises (TestError ):
2719- asyncio .get_event_loop ()
2720- self .assertEqual (cm .filename , __file__ )
2715+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2716+ asyncio .get_event_loop ()
27212717
27222718 with self .assertRaisesRegex (RuntimeError , 'no running' ):
27232719 asyncio .get_running_loop ()
@@ -2731,16 +2727,11 @@ async def func():
27312727 loop .run_until_complete (func ())
27322728
27332729 asyncio .set_event_loop (loop )
2734- with self .assertWarns (DeprecationWarning ) as cm :
2735- with self .assertRaises (TestError ):
2736- asyncio .get_event_loop ()
2737- self .assertEqual (cm .filename , __file__ )
2738-
2730+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2731+ asyncio .get_event_loop ()
27392732 asyncio .set_event_loop (None )
2740- with self .assertWarns (DeprecationWarning ) as cm :
2741- with self .assertRaises (TestError ):
2742- asyncio .get_event_loop ()
2743- self .assertEqual (cm .filename , __file__ )
2733+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2734+ asyncio .get_event_loop ()
27442735
27452736 finally :
27462737 asyncio .set_event_loop_policy (old_policy )
@@ -2759,15 +2750,11 @@ def test_get_event_loop_returns_running_loop2(self):
27592750 loop = asyncio .new_event_loop ()
27602751 self .addCleanup (loop .close )
27612752
2762- with self .assertWarns (DeprecationWarning ) as cm :
2763- loop2 = asyncio .get_event_loop ()
2764- self .addCleanup (loop2 .close )
2765- self .assertEqual (cm .filename , __file__ )
2753+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2754+ asyncio .get_event_loop ()
27662755 asyncio .set_event_loop (None )
2767- with self .assertWarns (DeprecationWarning ) as cm :
2768- with self .assertRaisesRegex (RuntimeError , 'no current' ):
2769- asyncio .get_event_loop ()
2770- self .assertEqual (cm .filename , __file__ )
2756+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2757+ asyncio .get_event_loop ()
27712758
27722759 with self .assertRaisesRegex (RuntimeError , 'no running' ):
27732760 asyncio .get_running_loop ()
@@ -2781,15 +2768,11 @@ async def func():
27812768 loop .run_until_complete (func ())
27822769
27832770 asyncio .set_event_loop (loop )
2784- with self .assertWarns ( DeprecationWarning ) as cm :
2771+ with self .assertRaisesRegex ( RuntimeError , 'no running' ) :
27852772 self .assertIs (asyncio .get_event_loop (), loop )
2786- self .assertEqual (cm .filename , __file__ )
2787-
27882773 asyncio .set_event_loop (None )
2789- with self .assertWarns (DeprecationWarning ) as cm :
2790- with self .assertRaisesRegex (RuntimeError , 'no current' ):
2791- asyncio .get_event_loop ()
2792- self .assertEqual (cm .filename , __file__ )
2774+ with self .assertRaisesRegex (RuntimeError , 'no running' ):
2775+ asyncio .get_event_loop ()
27932776
27942777 finally :
27952778 asyncio .set_event_loop_policy (old_policy )
@@ -2807,7 +2790,7 @@ class TestPyGetEventLoop(GetEventLoopTestsMixin, unittest.TestCase):
28072790 _get_running_loop_impl = events ._py__get_running_loop
28082791 _set_running_loop_impl = events ._py__set_running_loop
28092792 get_running_loop_impl = events ._py_get_running_loop
2810- get_event_loop_impl = events ._py_get_event_loop
2793+ get_event_loop_impl = events ._py_get_running_loop
28112794
28122795
28132796try :
@@ -2821,7 +2804,7 @@ class TestCGetEventLoop(GetEventLoopTestsMixin, unittest.TestCase):
28212804 _get_running_loop_impl = events ._c__get_running_loop
28222805 _set_running_loop_impl = events ._c__set_running_loop
28232806 get_running_loop_impl = events ._c_get_running_loop
2824- get_event_loop_impl = events ._c_get_event_loop
2807+ get_event_loop_impl = events ._c_get_running_loop
28252808
28262809
28272810class TestServer (unittest .TestCase ):
0 commit comments