bpo-40275: Avoid importing asyncio in test.support (GH-19600)

* Import asyncio lazily in unittest (only when IsolatedAsyncioTestCase is used).
* Import asyncio.events lazily in test.support.
This commit is contained in:
Serhiy Storchaka 2020-04-25 10:04:10 +03:00 committed by GitHub
parent d4f3923d59
commit 3c8a5b459d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -3,7 +3,6 @@
if __name__ != 'test.support':
raise ImportError('support must be imported from the test package')
import asyncio.events
import collections.abc
import contextlib
import errno
@ -3260,6 +3259,7 @@ SMALLEST = _SMALLEST()
def maybe_get_event_loop_policy():
"""Return the global event loop policy if one is set, else return None."""
import asyncio.events
return asyncio.events._event_loop_policy
# Helpers for testing hashing.