3838from test .support import ALWAYS_EQ , LARGEST , SMALLEST
3939
4040def tearDownModule ():
41- asyncio ._set_event_loop_policy (None )
41+ asyncio .events . _set_event_loop_policy (None )
4242
4343
4444def broken_unix_getsockname ():
@@ -2843,21 +2843,21 @@ def test_default_event_loop_policy_deprecation(self):
28432843 self .assertIsInstance (policy , asyncio .DefaultEventLoopPolicy )
28442844
28452845 def test_event_loop_policy (self ):
2846- policy = asyncio ._AbstractEventLoopPolicy ()
2846+ policy = asyncio .events . _AbstractEventLoopPolicy ()
28472847 self .assertRaises (NotImplementedError , policy .get_event_loop )
28482848 self .assertRaises (NotImplementedError , policy .set_event_loop , object ())
28492849 self .assertRaises (NotImplementedError , policy .new_event_loop )
28502850
28512851 def test_get_event_loop (self ):
2852- policy = asyncio . _DefaultEventLoopPolicy ()
2852+ policy = test_utils . DefaultEventLoopPolicy ()
28532853 self .assertIsNone (policy ._local ._loop )
28542854
28552855 with self .assertRaises (RuntimeError ):
28562856 loop = policy .get_event_loop ()
28572857 self .assertIsNone (policy ._local ._loop )
28582858
28592859 def test_get_event_loop_does_not_call_set_event_loop (self ):
2860- policy = asyncio . _DefaultEventLoopPolicy ()
2860+ policy = test_utils . DefaultEventLoopPolicy ()
28612861
28622862 with mock .patch .object (
28632863 policy , "set_event_loop" ,
@@ -2869,30 +2869,30 @@ def test_get_event_loop_does_not_call_set_event_loop(self):
28692869 m_set_event_loop .assert_not_called ()
28702870
28712871 def test_get_event_loop_after_set_none (self ):
2872- policy = asyncio . _DefaultEventLoopPolicy ()
2872+ policy = test_utils . DefaultEventLoopPolicy ()
28732873 policy .set_event_loop (None )
28742874 self .assertRaises (RuntimeError , policy .get_event_loop )
28752875
28762876 @mock .patch ('asyncio.events.threading.current_thread' )
28772877 def test_get_event_loop_thread (self , m_current_thread ):
28782878
28792879 def f ():
2880- policy = asyncio . _DefaultEventLoopPolicy ()
2880+ policy = test_utils . DefaultEventLoopPolicy ()
28812881 self .assertRaises (RuntimeError , policy .get_event_loop )
28822882
28832883 th = threading .Thread (target = f )
28842884 th .start ()
28852885 th .join ()
28862886
28872887 def test_new_event_loop (self ):
2888- policy = asyncio . _DefaultEventLoopPolicy ()
2888+ policy = test_utils . DefaultEventLoopPolicy ()
28892889
28902890 loop = policy .new_event_loop ()
28912891 self .assertIsInstance (loop , asyncio .AbstractEventLoop )
28922892 loop .close ()
28932893
28942894 def test_set_event_loop (self ):
2895- policy = asyncio . _DefaultEventLoopPolicy ()
2895+ policy = test_utils . DefaultEventLoopPolicy ()
28962896 old_loop = policy .new_event_loop ()
28972897 policy .set_event_loop (old_loop )
28982898
@@ -2909,7 +2909,7 @@ def test_get_event_loop_policy(self):
29092909 with self .assertWarnsRegex (
29102910 DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
29112911 policy = asyncio .get_event_loop_policy ()
2912- self .assertIsInstance (policy , asyncio ._AbstractEventLoopPolicy )
2912+ self .assertIsInstance (policy , asyncio .events . _AbstractEventLoopPolicy )
29132913 self .assertIs (policy , asyncio .get_event_loop_policy ())
29142914
29152915 def test_set_event_loop_policy (self ):
@@ -2922,7 +2922,7 @@ def test_set_event_loop_policy(self):
29222922 DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
29232923 old_policy = asyncio .get_event_loop_policy ()
29242924
2925- policy = asyncio . _DefaultEventLoopPolicy ()
2925+ policy = test_utils . DefaultEventLoopPolicy ()
29262926 with self .assertWarnsRegex (
29272927 DeprecationWarning , "'asyncio.set_event_loop_policy' is deprecated" ):
29282928 asyncio .set_event_loop_policy (policy )
@@ -3034,13 +3034,13 @@ def test_get_event_loop_returns_running_loop(self):
30343034 class TestError (Exception ):
30353035 pass
30363036
3037- class Policy (asyncio . _DefaultEventLoopPolicy ):
3037+ class Policy (test_utils . DefaultEventLoopPolicy ):
30383038 def get_event_loop (self ):
30393039 raise TestError
30403040
3041- old_policy = asyncio ._get_event_loop_policy ()
3041+ old_policy = asyncio .events . _get_event_loop_policy ()
30423042 try :
3043- asyncio ._set_event_loop_policy (Policy ())
3043+ asyncio .events . _set_event_loop_policy (Policy ())
30443044 loop = asyncio .new_event_loop ()
30453045
30463046 with self .assertRaises (TestError ):
@@ -3068,7 +3068,7 @@ async def func():
30683068 asyncio .get_event_loop ()
30693069
30703070 finally :
3071- asyncio ._set_event_loop_policy (old_policy )
3071+ asyncio .events . _set_event_loop_policy (old_policy )
30723072 if loop is not None :
30733073 loop .close ()
30743074
@@ -3078,9 +3078,9 @@ async def func():
30783078 self .assertIs (asyncio ._get_running_loop (), None )
30793079
30803080 def test_get_event_loop_returns_running_loop2 (self ):
3081- old_policy = asyncio ._get_event_loop_policy ()
3081+ old_policy = asyncio .events . _get_event_loop_policy ()
30823082 try :
3083- asyncio ._set_event_loop_policy (asyncio . _DefaultEventLoopPolicy ())
3083+ asyncio .events . _set_event_loop_policy (test_utils . DefaultEventLoopPolicy ())
30843084 loop = asyncio .new_event_loop ()
30853085 self .addCleanup (loop .close )
30863086
@@ -3106,7 +3106,7 @@ async def func():
31063106 asyncio .get_event_loop ()
31073107
31083108 finally :
3109- asyncio ._set_event_loop_policy (old_policy )
3109+ asyncio .events . _set_event_loop_policy (old_policy )
31103110 if loop is not None :
31113111 loop .close ()
31123112
0 commit comments