diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-08-15 22:01:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-15 22:01:23 (GMT) |
commit | 8bd7a0b5810529cd3ed378de42a74e9301856f12 (patch) | |
tree | 8694a7367a7b68d1f702ef38ab818bac2bd2d5c0 /Lib/test/test_asyncio | |
parent | 3fa97b8589c551e70ec935e7f39d56c3c5d5ed7e (diff) | |
download | cpython-8bd7a0b5810529cd3ed378de42a74e9301856f12.zip cpython-8bd7a0b5810529cd3ed378de42a74e9301856f12.tar.gz cpython-8bd7a0b5810529cd3ed378de42a74e9301856f12.tar.bz2 |
GH-95899: fix asyncio.Runner to call set_event_loop only once (GH-95900) (#96003)
(cherry picked from commit 914f6367a0d015986dafa7a9d542e24192753b6b)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_runners.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_runners.py b/Lib/test/test_asyncio/test_runners.py index 5e1db23..4e3acb9 100644 --- a/Lib/test/test_asyncio/test_runners.py +++ b/Lib/test/test_asyncio/test_runners.py @@ -456,6 +456,20 @@ class RunnerTests(BaseTest): ): runner.run(coro()) + def test_set_event_loop_called_once(self): + # See https://github.com/python/cpython/issues/95736 + async def coro(): + pass + + policy = asyncio.get_event_loop_policy() + policy.set_event_loop = mock.Mock() + runner = asyncio.Runner() + runner.run(coro()) + runner.run(coro()) + + self.assertEqual(1, policy.set_event_loop.call_count) + runner.close() + if __name__ == '__main__': unittest.main() |