mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-118761: Add helper to ensure that lazy imports are actually lazy (#132614)
This ensures that if we jump through some hoops to make sure something is imported lazily, we don't regress on importing it. I recently already accidentally made typing import warnings and annotationlib eagerly. Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
b530e174a3
commit
39ee468e09
3 changed files with 39 additions and 0 deletions
|
@ -24,6 +24,7 @@ from typing import (
|
|||
)
|
||||
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from test.test_inspect import inspect_stock_annotations
|
||||
from test.test_inspect import inspect_stringized_annotations
|
||||
from test.test_inspect import inspect_stringized_annotations_2
|
||||
|
@ -1367,3 +1368,9 @@ class ForwardRefTests(unittest.TestCase):
|
|||
class TestAnnotationLib(unittest.TestCase):
|
||||
def test__all__(self):
|
||||
support.check__all__(self, annotationlib)
|
||||
|
||||
def test_lazy_imports(self):
|
||||
import_helper.ensure_lazy_imports("annotationlib", {
|
||||
"typing",
|
||||
"warnings",
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue