GH-93896: always set event loop in asyncio.run and IsolatedAsyncioTestCase by kumaraditya303 · Pull Request #94593 · python/cpython · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Lib/asyncio/runners.py
12 changes: 12 additions & 0 deletions Lib/test/test_asyncio/test_runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ async def main():
self.assertIsNone(spinner.ag_frame)
self.assertFalse(spinner.ag_running)

def test_asyncio_run_set_event_loop(self):
#See https://github.com/python/cpython/issues/93896

async def main():
await asyncio.sleep(0)
return 42

policy = asyncio.get_event_loop_policy()
policy.set_event_loop = mock.Mock()
asyncio.run(main())
self.assertTrue(policy.set_event_loop.called)


class RunnerTests(BaseTest):

Expand Down