◐ Shell
clean mode source ↗

gh-130322: drop deprecation of `asyncio.set_event_loop` by kumaraditya303 · Pull Request #132349 · python/cpython

Expand Up @@ -57,7 +57,7 @@ async def doit(): return 'hello'
with contextlib.closing(asyncio.new_event_loop()) as loop: asyncio._set_event_loop(loop) asyncio.set_event_loop(loop) return loop.run_until_complete(doit())

Expand Down Expand Up @@ -2830,14 +2830,6 @@ async def inner():
class PolicyTests(unittest.TestCase):
def test_asyncio_set_event_loop_deprecation(self): with self.assertWarnsRegex( DeprecationWarning, "'asyncio.set_event_loop' is deprecated"): loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) self.assertIs(loop, asyncio.get_event_loop()) loop.close()
def test_abstract_event_loop_policy_deprecation(self): with self.assertWarnsRegex( DeprecationWarning, "'asyncio.AbstractEventLoopPolicy' is deprecated"): Expand Down Expand Up @@ -2974,14 +2966,14 @@ def setUp(self): super().setUp()
self.loop = asyncio.new_event_loop() asyncio._set_event_loop(self.loop) asyncio.set_event_loop(self.loop)
def tearDown(self): try: super().tearDown() finally: self.loop.close() asyncio._set_event_loop(None) asyncio.set_event_loop(None)
events._get_running_loop = self._get_running_loop_saved events._set_running_loop = self._set_running_loop_saved Expand Down Expand Up @@ -3053,7 +3045,7 @@ def get_event_loop(self):
with self.assertRaises(TestError): asyncio.get_event_loop() asyncio._set_event_loop(None) asyncio.set_event_loop(None) with self.assertRaises(TestError): asyncio.get_event_loop()
Expand All @@ -3068,10 +3060,10 @@ async def func():
loop.run_until_complete(func())
asyncio._set_event_loop(loop) asyncio.set_event_loop(loop) with self.assertRaises(TestError): asyncio.get_event_loop() asyncio._set_event_loop(None) asyncio.set_event_loop(None) with self.assertRaises(TestError): asyncio.get_event_loop()
Expand All @@ -3095,7 +3087,7 @@ def test_get_event_loop_returns_running_loop2(self): with self.assertRaisesRegex(RuntimeError, 'no current'): asyncio.get_event_loop()
asyncio._set_event_loop(None) asyncio.set_event_loop(None) with self.assertRaisesRegex(RuntimeError, 'no current'): asyncio.get_event_loop()
Expand All @@ -3106,10 +3098,10 @@ async def func():
loop.run_until_complete(func())
asyncio._set_event_loop(loop) asyncio.set_event_loop(loop) self.assertIs(asyncio.get_event_loop(), loop)
asyncio._set_event_loop(None) asyncio.set_event_loop(None) with self.assertRaisesRegex(RuntimeError, 'no current'): asyncio.get_event_loop()
Expand Down