File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919test.test_inspect.test_inspect
2020test___all__
2121test__interpreters
22- test_clinic
2322test_crossinterp
2423test_datetime
25- test_generated_cases
2624test_import
2725test_importlib
2826test_json
@@ -32,6 +30,5 @@ test_profiling
3230test_pyrepl
3331test_subprocess
3432test_symtable
35- test_tools
3633test_type_annotations
3734test_unittest
Original file line number Diff line number Diff line change @@ -119,6 +119,20 @@ def frozen_modules(enabled=True):
119119 _imp ._override_frozen_modules_for_tests (0 )
120120
121121
122+ @contextlib .contextmanager
123+ def force_eager_imports ():
124+ """Force eager imports inside the context manager."""
125+ original_lazy_imports_filter = sys .get_lazy_imports_filter ()
126+ sys .set_lazy_imports_filter (
127+ # Tools must be imported eagerly under this context manager:
128+ lambda importing , imported , fromlist : False
129+ )
130+ try :
131+ yield
132+ finally :
133+ sys .set_lazy_imports_filter (original_lazy_imports_filter )
134+
135+
122136@contextlib .contextmanager
123137def multi_interp_extensions_check (enabled = True ):
124138 """Force legacy modules to be allowed in subinterpreters (or not).
Original file line number Diff line number Diff line change @@ -32,7 +32,10 @@ def skip_if_missing(tool=None):
3232@contextlib .contextmanager
3333def imports_under_tool (name , * subdirs ):
3434 tooldir = os .path .join (toolsdir , name , * subdirs )
35- with import_helper .DirsOnSysPath (tooldir ) as cm :
35+ with (
36+ import_helper .force_eager_imports (),
37+ import_helper .DirsOnSysPath (tooldir ) as cm ,
38+ ):
3639 yield cm
3740
3841def import_tool (toolname ):
You can’t perform that action at this time.
0 commit comments