@@ -2695,22 +2695,34 @@ async def inner():
26952695
26962696class PolicyTests (unittest .TestCase ):
26972697
2698+ def test_abstract_event_loop_policy_deprecation (self ):
2699+ with self .assertWarnsRegex (
2700+ DeprecationWarning , "'asyncio.AbstractEventLoopPolicy' is deprecated" ):
2701+ policy = asyncio .AbstractEventLoopPolicy ()
2702+ self .assertIsInstance (policy , asyncio .AbstractEventLoopPolicy )
2703+
2704+ def test_default_event_loop_policy_deprecation (self ):
2705+ with self .assertWarnsRegex (
2706+ DeprecationWarning , "'asyncio.DefaultEventLoopPolicy' is deprecated" ):
2707+ policy = asyncio .DefaultEventLoopPolicy ()
2708+ self .assertIsInstance (policy , asyncio .DefaultEventLoopPolicy )
2709+
26982710 def test_event_loop_policy (self ):
2699- policy = asyncio .AbstractEventLoopPolicy ()
2711+ policy = asyncio ._AbstractEventLoopPolicy ()
27002712 self .assertRaises (NotImplementedError , policy .get_event_loop )
27012713 self .assertRaises (NotImplementedError , policy .set_event_loop , object ())
27022714 self .assertRaises (NotImplementedError , policy .new_event_loop )
27032715
27042716 def test_get_event_loop (self ):
2705- policy = asyncio .DefaultEventLoopPolicy ()
2717+ policy = asyncio ._DefaultEventLoopPolicy ()
27062718 self .assertIsNone (policy ._local ._loop )
27072719
27082720 with self .assertRaises (RuntimeError ):
27092721 loop = policy .get_event_loop ()
27102722 self .assertIsNone (policy ._local ._loop )
27112723
27122724 def test_get_event_loop_does_not_call_set_event_loop (self ):
2713- policy = asyncio .DefaultEventLoopPolicy ()
2725+ policy = asyncio ._DefaultEventLoopPolicy ()
27142726
27152727 with mock .patch .object (
27162728 policy , "set_event_loop" ,
@@ -2722,30 +2734,30 @@ def test_get_event_loop_does_not_call_set_event_loop(self):
27222734 m_set_event_loop .assert_not_called ()
27232735
27242736 def test_get_event_loop_after_set_none (self ):
2725- policy = asyncio .DefaultEventLoopPolicy ()
2737+ policy = asyncio ._DefaultEventLoopPolicy ()
27262738 policy .set_event_loop (None )
27272739 self .assertRaises (RuntimeError , policy .get_event_loop )
27282740
27292741 @mock .patch ('asyncio.events.threading.current_thread' )
27302742 def test_get_event_loop_thread (self , m_current_thread ):
27312743
27322744 def f ():
2733- policy = asyncio .DefaultEventLoopPolicy ()
2745+ policy = asyncio ._DefaultEventLoopPolicy ()
27342746 self .assertRaises (RuntimeError , policy .get_event_loop )
27352747
27362748 th = threading .Thread (target = f )
27372749 th .start ()
27382750 th .join ()
27392751
27402752 def test_new_event_loop (self ):
2741- policy = asyncio .DefaultEventLoopPolicy ()
2753+ policy = asyncio ._DefaultEventLoopPolicy ()
27422754
27432755 loop = policy .new_event_loop ()
27442756 self .assertIsInstance (loop , asyncio .AbstractEventLoop )
27452757 loop .close ()
27462758
27472759 def test_set_event_loop (self ):
2748- policy = asyncio .DefaultEventLoopPolicy ()
2760+ policy = asyncio ._DefaultEventLoopPolicy ()
27492761 old_loop = policy .new_event_loop ()
27502762 policy .set_event_loop (old_loop )
27512763
@@ -2762,7 +2774,7 @@ def test_get_event_loop_policy(self):
27622774 with self .assertWarnsRegex (
27632775 DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
27642776 policy = asyncio .get_event_loop_policy ()
2765- self .assertIsInstance (policy , asyncio .AbstractEventLoopPolicy )
2777+ self .assertIsInstance (policy , asyncio ._AbstractEventLoopPolicy )
27662778 self .assertIs (policy , asyncio .get_event_loop_policy ())
27672779
27682780 def test_set_event_loop_policy (self ):
@@ -2775,7 +2787,7 @@ def test_set_event_loop_policy(self):
27752787 DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
27762788 old_policy = asyncio .get_event_loop_policy ()
27772789
2778- policy = asyncio .DefaultEventLoopPolicy ()
2790+ policy = asyncio ._DefaultEventLoopPolicy ()
27792791 with self .assertWarnsRegex (
27802792 DeprecationWarning , "'asyncio.set_event_loop_policy' is deprecated" ):
27812793 asyncio .set_event_loop_policy (policy )
@@ -2862,7 +2874,7 @@ def test_get_event_loop_returns_running_loop(self):
28622874 class TestError (Exception ):
28632875 pass
28642876
2865- class Policy (asyncio .DefaultEventLoopPolicy ):
2877+ class Policy (asyncio ._DefaultEventLoopPolicy ):
28662878 def get_event_loop (self ):
28672879 raise TestError
28682880
@@ -2908,7 +2920,7 @@ async def func():
29082920 def test_get_event_loop_returns_running_loop2 (self ):
29092921 old_policy = asyncio ._get_event_loop_policy ()
29102922 try :
2911- asyncio ._set_event_loop_policy (asyncio .DefaultEventLoopPolicy ())
2923+ asyncio ._set_event_loop_policy (asyncio ._DefaultEventLoopPolicy ())
29122924 loop = asyncio .new_event_loop ()
29132925 self .addCleanup (loop .close )
29142926
0 commit comments