@@ -2397,7 +2397,7 @@ def test_handle_repr_debug(self):
2397
2397
self .assertRegex (repr (h ), regex )
2398
2398
2399
2399
def test_handle_source_traceback (self ):
2400
- loop = asyncio .get_event_loop_policy (). new_event_loop ()
2400
+ loop = asyncio .new_event_loop ()
2401
2401
loop .set_debug (True )
2402
2402
self .set_event_loop (loop )
2403
2403
@@ -2759,24 +2759,31 @@ def test_set_event_loop(self):
2759
2759
old_loop .close ()
2760
2760
2761
2761
def test_get_event_loop_policy (self ):
2762
- policy = asyncio .get_event_loop_policy ()
2763
- self .assertIsInstance (policy , asyncio .AbstractEventLoopPolicy )
2764
- self .assertIs (policy , asyncio .get_event_loop_policy ())
2762
+ with self .assertWarnsRegex (
2763
+ DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
2764
+ policy = asyncio .get_event_loop_policy ()
2765
+ self .assertIsInstance (policy , asyncio .AbstractEventLoopPolicy )
2766
+ self .assertIs (policy , asyncio .get_event_loop_policy ())
2765
2767
2766
2768
def test_set_event_loop_policy (self ):
2767
2769
with self .assertWarnsRegex (
2768
- DeprecationWarning , "'set_event_loop_policy' is deprecated" ):
2770
+ DeprecationWarning , "'asyncio. set_event_loop_policy' is deprecated" ):
2769
2771
self .assertRaises (
2770
2772
TypeError , asyncio .set_event_loop_policy , object ())
2771
2773
2772
- old_policy = asyncio .get_event_loop_policy ()
2774
+ with self .assertWarnsRegex (
2775
+ DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
2776
+ old_policy = asyncio .get_event_loop_policy ()
2773
2777
2774
2778
policy = asyncio .DefaultEventLoopPolicy ()
2775
2779
with self .assertWarnsRegex (
2776
- DeprecationWarning , "'set_event_loop_policy' is deprecated" ):
2780
+ DeprecationWarning , "'asyncio. set_event_loop_policy' is deprecated" ):
2777
2781
asyncio .set_event_loop_policy (policy )
2778
- self .assertIs (policy , asyncio .get_event_loop_policy ())
2779
- self .assertIsNot (policy , old_policy )
2782
+
2783
+ with self .assertWarnsRegex (
2784
+ DeprecationWarning , "'asyncio.get_event_loop_policy' is deprecated" ):
2785
+ self .assertIs (policy , asyncio .get_event_loop_policy ())
2786
+ self .assertIsNot (policy , old_policy )
2780
2787
2781
2788
2782
2789
class GetEventLoopTestsMixin :
@@ -2859,7 +2866,7 @@ class Policy(asyncio.DefaultEventLoopPolicy):
2859
2866
def get_event_loop (self ):
2860
2867
raise TestError
2861
2868
2862
- old_policy = asyncio .get_event_loop_policy ()
2869
+ old_policy = asyncio ._get_event_loop_policy ()
2863
2870
try :
2864
2871
asyncio ._set_event_loop_policy (Policy ())
2865
2872
loop = asyncio .new_event_loop ()
@@ -2899,7 +2906,7 @@ async def func():
2899
2906
self .assertIs (asyncio ._get_running_loop (), None )
2900
2907
2901
2908
def test_get_event_loop_returns_running_loop2 (self ):
2902
- old_policy = asyncio .get_event_loop_policy ()
2909
+ old_policy = asyncio ._get_event_loop_policy ()
2903
2910
try :
2904
2911
asyncio ._set_event_loop_policy (asyncio .DefaultEventLoopPolicy ())
2905
2912
loop = asyncio .new_event_loop ()
0 commit comments