mirror of
https://github.com/python/cpython.git
synced 2025-10-28 12:15:13 +00:00
[3.14] gh-134657: Remove newly added private names from asyncio.__all__ (GH-134665) (#136455)
gh-134657: Remove newly added private names from asyncio.__all__ (GH-134665)
(cherry picked from commit 797abd1f7f)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
parent
a9d2f08b57
commit
c29fce05f3
47 changed files with 105 additions and 90 deletions
|
|
@ -12,14 +12,14 @@
|
|||
|
||||
|
||||
def tearDownModule():
|
||||
asyncio._set_event_loop_policy(None)
|
||||
asyncio.events._set_event_loop_policy(None)
|
||||
|
||||
|
||||
def interrupt_self():
|
||||
_thread.interrupt_main()
|
||||
|
||||
|
||||
class TestPolicy(asyncio._AbstractEventLoopPolicy):
|
||||
class TestPolicy(asyncio.events._AbstractEventLoopPolicy):
|
||||
|
||||
def __init__(self, loop_factory):
|
||||
self.loop_factory = loop_factory
|
||||
|
|
@ -61,15 +61,15 @@ def setUp(self):
|
|||
super().setUp()
|
||||
|
||||
policy = TestPolicy(self.new_loop)
|
||||
asyncio._set_event_loop_policy(policy)
|
||||
asyncio.events._set_event_loop_policy(policy)
|
||||
|
||||
def tearDown(self):
|
||||
policy = asyncio._get_event_loop_policy()
|
||||
policy = asyncio.events._get_event_loop_policy()
|
||||
if policy.loop is not None:
|
||||
self.assertTrue(policy.loop.is_closed())
|
||||
self.assertTrue(policy.loop.shutdown_ag_run)
|
||||
|
||||
asyncio._set_event_loop_policy(None)
|
||||
asyncio.events._set_event_loop_policy(None)
|
||||
super().tearDown()
|
||||
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ async def main():
|
|||
await asyncio.sleep(0)
|
||||
return 42
|
||||
|
||||
policy = asyncio._get_event_loop_policy()
|
||||
policy = asyncio.events._get_event_loop_policy()
|
||||
policy.set_event_loop = mock.Mock()
|
||||
asyncio.run(main())
|
||||
self.assertTrue(policy.set_event_loop.called)
|
||||
|
|
@ -259,7 +259,7 @@ def new_event_loop():
|
|||
loop.set_task_factory(Task)
|
||||
return loop
|
||||
|
||||
asyncio._set_event_loop_policy(TestPolicy(new_event_loop))
|
||||
asyncio.events._set_event_loop_policy(TestPolicy(new_event_loop))
|
||||
with self.assertRaises(asyncio.CancelledError):
|
||||
asyncio.run(main())
|
||||
|
||||
|
|
@ -495,7 +495,7 @@ def test_set_event_loop_called_once(self):
|
|||
async def coro():
|
||||
pass
|
||||
|
||||
policy = asyncio._get_event_loop_policy()
|
||||
policy = asyncio.events._get_event_loop_policy()
|
||||
policy.set_event_loop = mock.Mock()
|
||||
runner = asyncio.Runner()
|
||||
runner.run(coro())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue