diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-01-13 12:40:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 12:40:29 (GMT) |
commit | e5bd5ad70d9e549eeb80aadb4f3ccb0f2f23266d (patch) | |
tree | 3c13553b04873b8cd80d10a877740031aa324b31 /Lib/test/test_asyncio/test_unix_events.py | |
parent | 468c3bf79890ef614764b4e7543608876c792794 (diff) | |
download | cpython-e5bd5ad70d9e549eeb80aadb4f3ccb0f2f23266d.zip cpython-e5bd5ad70d9e549eeb80aadb4f3ccb0f2f23266d.tar.gz cpython-e5bd5ad70d9e549eeb80aadb4f3ccb0f2f23266d.tar.bz2 |
gh-100160: Restore and deprecate implicit creation of an event loop (GH-100410)
Partially revert changes made in GH-93453.
asyncio.DefaultEventLoopPolicy.get_event_loop() now emits a
DeprecationWarning and creates and sets a new event loop instead of
raising a RuntimeError if there is no current event loop set.
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Diffstat (limited to 'Lib/test/test_asyncio/test_unix_events.py')
-rw-r--r-- | Lib/test/test_asyncio/test_unix_events.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_unix_events.py b/Lib/test/test_asyncio/test_unix_events.py index 600a590..33d0ea1 100644 --- a/Lib/test/test_asyncio/test_unix_events.py +++ b/Lib/test/test_asyncio/test_unix_events.py @@ -1884,7 +1884,9 @@ class TestFork(unittest.IsolatedAsyncioTestCase): if pid == 0: # child try: - loop = asyncio.get_event_loop_policy().get_event_loop() + with self.assertWarns(DeprecationWarning): + loop = asyncio.get_event_loop_policy().get_event_loop() + os.write(w, b'LOOP:' + str(id(loop)).encode()) except RuntimeError: os.write(w, b'NO LOOP') except: @@ -1893,7 +1895,9 @@ class TestFork(unittest.IsolatedAsyncioTestCase): os._exit(0) else: # parent - self.assertEqual(os.read(r, 100), b'NO LOOP') + result = os.read(r, 100) + self.assertEqual(result[:5], b'LOOP:', result) + self.assertNotEqual(int(result[5:]), id(loop)) wait_process(pid, exitcode=0) @hashlib_helper.requires_hashdigest('md5') |