diff options
author | Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> | 2022-07-06 15:18:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 15:18:21 (GMT) |
commit | 14fea6b4d25658bc00adbb97dd40ea3d3e6843ad (patch) | |
tree | 7b5f24a0085968ed234761e74cc96c9dc2dd99b0 /Lib/test/test_asyncio | |
parent | e925241d95d8095adf67f492042f97254ff82ec1 (diff) | |
download | cpython-14fea6b4d25658bc00adbb97dd40ea3d3e6843ad.zip cpython-14fea6b4d25658bc00adbb97dd40ea3d3e6843ad.tar.gz cpython-14fea6b4d25658bc00adbb97dd40ea3d3e6843ad.tar.bz2 |
GH-93896: AAlways set event loop in asyncio.run and IsolatedAsyncioTestCase (#94593)
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_runners.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 7780a5f..1f6a498 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -198,6 +198,18 @@ class RunTests(BaseTest): 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): |