mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
[3.11] gh-100160: Remove any deprecation warnings in asyncio.get_event_loop() (#100412)
Some deprecation warnings will reappear (in a slightly different form) in 3.12. Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
a7f9afdd46
commit
1b2459dc64
6 changed files with 17 additions and 48 deletions
|
@ -2588,9 +2588,7 @@ class PolicyTests(unittest.TestCase):
|
|||
def test_get_event_loop(self):
|
||||
policy = asyncio.DefaultEventLoopPolicy()
|
||||
self.assertIsNone(policy._local._loop)
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
loop = policy.get_event_loop()
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
loop = policy.get_event_loop()
|
||||
self.assertIsInstance(loop, asyncio.AbstractEventLoop)
|
||||
|
||||
self.assertIs(policy._local._loop, loop)
|
||||
|
@ -2604,10 +2602,8 @@ class PolicyTests(unittest.TestCase):
|
|||
policy, "set_event_loop",
|
||||
wraps=policy.set_event_loop) as m_set_event_loop:
|
||||
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
loop = policy.get_event_loop()
|
||||
loop = policy.get_event_loop()
|
||||
self.addCleanup(loop.close)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
|
||||
# policy._local._loop must be set through .set_event_loop()
|
||||
# (the unix DefaultEventLoopPolicy needs this call to attach
|
||||
|
@ -2796,10 +2792,8 @@ class GetEventLoopTestsMixin:
|
|||
loop = asyncio.new_event_loop()
|
||||
self.addCleanup(loop.close)
|
||||
|
||||
with self.assertWarns(DeprecationWarning) as cm:
|
||||
loop2 = asyncio.get_event_loop()
|
||||
loop2 = asyncio.get_event_loop()
|
||||
self.addCleanup(loop2.close)
|
||||
self.assertEqual(cm.filename, __file__)
|
||||
asyncio.set_event_loop(None)
|
||||
with self.assertRaisesRegex(RuntimeError, 'no current'):
|
||||
asyncio.get_event_loop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue