39
39
40
40
41
41
def tearDownModule ():
42
- asyncio .set_event_loop_policy (None )
42
+ support .set_event_loop_policy (None )
43
43
44
44
45
45
def broken_unix_getsockname ():
@@ -2684,8 +2684,9 @@ def test_get_event_loop_policy(self):
2684
2684
self .assertIs (policy , asyncio .get_event_loop_policy ())
2685
2685
2686
2686
def test_set_event_loop_policy (self ):
2687
- self .assertRaises (
2688
- TypeError , asyncio .set_event_loop_policy , object ())
2687
+ with self .assertWarns (DeprecationWarning ):
2688
+ self .assertRaises (
2689
+ TypeError , asyncio .set_event_loop_policy , object ())
2689
2690
2690
2691
old_policy = asyncio .get_event_loop_policy ()
2691
2692
@@ -2790,7 +2791,8 @@ def get_event_loop(self):
2790
2791
2791
2792
old_policy = asyncio .get_event_loop_policy ()
2792
2793
try :
2793
- asyncio .set_event_loop_policy (Policy ())
2794
+ with self .assertWarns (DeprecationWarning ):
2795
+ asyncio .set_event_loop_policy (Policy ())
2794
2796
loop = asyncio .new_event_loop ()
2795
2797
2796
2798
with self .assertRaises (TestError ):
@@ -2818,7 +2820,7 @@ async def func():
2818
2820
asyncio .get_event_loop ()
2819
2821
2820
2822
finally :
2821
- asyncio .set_event_loop_policy (old_policy )
2823
+ support .set_event_loop_policy (old_policy )
2822
2824
if loop is not None :
2823
2825
loop .close ()
2824
2826
@@ -2830,7 +2832,8 @@ async def func():
2830
2832
def test_get_event_loop_returns_running_loop2 (self ):
2831
2833
old_policy = asyncio .get_event_loop_policy ()
2832
2834
try :
2833
- asyncio .set_event_loop_policy (asyncio .DefaultEventLoopPolicy ())
2835
+ with self .assertWarns (DeprecationWarning ):
2836
+ asyncio .set_event_loop_policy (asyncio .DefaultEventLoopPolicy ())
2834
2837
loop = asyncio .new_event_loop ()
2835
2838
self .addCleanup (loop .close )
2836
2839
@@ -2861,7 +2864,7 @@ async def func():
2861
2864
asyncio .get_event_loop ()
2862
2865
2863
2866
finally :
2864
- asyncio .set_event_loop_policy (old_policy )
2867
+ support .set_event_loop_policy (old_policy )
2865
2868
if loop is not None :
2866
2869
loop .close ()
2867
2870
0 commit comments