11import asyncio
22import contextvars
33import unittest
4+
45from test import support
6+ from test .support import force_not_colorized
57
68support .requires_working_socket (module = True )
79
@@ -11,7 +13,7 @@ class MyException(Exception):
1113
1214
1315def tearDownModule ():
14- asyncio .set_event_loop_policy (None )
16+ asyncio .events . _set_event_loop_policy (None )
1517
1618
1719class TestCM :
@@ -253,6 +255,7 @@ async def on_cleanup(self):
253255 test .doCleanups ()
254256 self .assertEqual (events , ['asyncSetUp' , 'test' , 'asyncTearDown' , 'cleanup' ])
255257
258+ @force_not_colorized
256259 def test_exception_in_tear_clean_up (self ):
257260 class Test (unittest .IsolatedAsyncioTestCase ):
258261 async def asyncSetUp (self ):
@@ -314,18 +317,21 @@ async def test3(self):
314317 self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
315318 self .assertIn ('test1' , str (w .warning ))
316319 self .assertEqual (w .filename , __file__ )
320+ self .assertIn ("returned 'int'" , str (w .warning ))
317321
318322 with self .assertWarns (DeprecationWarning ) as w :
319323 Test ('test2' ).run ()
320324 self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
321325 self .assertIn ('test2' , str (w .warning ))
322326 self .assertEqual (w .filename , __file__ )
327+ self .assertIn ("returned 'async_generator'" , str (w .warning ))
323328
324329 with self .assertWarns (DeprecationWarning ) as w :
325330 Test ('test3' ).run ()
326331 self .assertIn ('It is deprecated to return a value that is not None' , str (w .warning ))
327332 self .assertIn ('test3' , str (w .warning ))
328333 self .assertEqual (w .filename , __file__ )
334+ self .assertIn (f'returned { Nothing .__name__ !r} ' , str (w .warning ))
329335
330336 def test_cleanups_interleave_order (self ):
331337 events = []
@@ -477,7 +483,7 @@ def test_setup_get_event_loop(self):
477483
478484 class TestCase1 (unittest .IsolatedAsyncioTestCase ):
479485 def setUp (self ):
480- asyncio .get_event_loop_policy ().get_event_loop ()
486+ asyncio .events . _get_event_loop_policy ().get_event_loop ()
481487
482488 async def test_demo1 (self ):
483489 pass
@@ -487,7 +493,7 @@ async def test_demo1(self):
487493 self .assertTrue (result .wasSuccessful ())
488494
489495 def test_loop_factory (self ):
490- asyncio .set_event_loop_policy (None )
496+ asyncio .events . _set_event_loop_policy (None )
491497
492498 class TestCase1 (unittest .IsolatedAsyncioTestCase ):
493499 loop_factory = asyncio .EventLoop
0 commit comments