Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Lib/test/lazy_imports_all_exclude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ test.test_inspect.test_inspect
test___all__
test__interpreters
test_crossinterp
test_datetime
test_import
test_importlib
test_json
test_pkg
test_profile
test_profiling
Expand Down
8 changes: 7 additions & 1 deletion Lib/test/support/import_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def multi_interp_extensions_check(enabled=True):
def import_fresh_module(name, fresh=(), blocked=(), *,
deprecated=False,
usefrozen=False,
eager_imports=True,
):
"""Import and return a module, deliberately bypassing sys.modules.
Expand Down Expand Up @@ -187,7 +188,12 @@ def import_fresh_module(name, fresh=(), blocked=(), *,
"""
# NOTE: test_heapq, test_json and test_warnings include extra sanity checks
# to make sure that this utility function is working as expected
with _ignore_deprecated_imports(deprecated):
eager_imports_context = (
force_eager_imports
if eager_imports
else contextlib.nullcontext
)
with eager_imports_context(), _ignore_deprecated_imports(deprecated):
# Keep track of modules saved for later restoration as well
# as those which just need a blocking entry removed
fresh = list(fresh)
Expand Down
6 changes: 5 additions & 1 deletion Lib/test/test_type_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,11 @@ class D(metaclass=C):
self.assertEqual(D.__annotations__, {})

def test_partially_executed_module(self):
partialexe = import_helper.import_fresh_module("test.typinganndata.partialexecution")
# Results are different with and without lazy imports, we need both:
partialexe = import_helper.import_fresh_module(
"test.typinganndata.partialexecution",
eager_imports=False,
)
self.assertEqual(
partialexe.a.__annotations__,
{"v1": int, "v2": int},
Expand Down
Loading