1111import tempfile
1212import os
1313
14+ from test import support
15+
1416try :
1517 import _testcapi
1618except ImportError :
@@ -268,6 +270,7 @@ def f():
268270 f ()
269271 self .assertIn ("only allowed at module level" , str (cm .exception ))
270272
273+ @support .requires_subprocess ()
271274 def test_lazy_import_exec_at_module_level (self ):
272275 """lazy import via exec() at module level should work."""
273276 # exec() at module level (globals == locals) should allow lazy imports
@@ -469,6 +472,7 @@ def test_lazy_modules_attribute_is_set(self):
469472 """sys.lazy_modules should be a set per PEP 810."""
470473 self .assertIsInstance (sys .lazy_modules , dict )
471474
475+ @support .requires_subprocess ()
472476 def test_lazy_modules_tracks_lazy_imports (self ):
473477 """sys.lazy_modules should track lazily imported module names."""
474478 code = textwrap .dedent ("""
@@ -489,6 +493,7 @@ def test_lazy_modules_tracks_lazy_imports(self):
489493 self .assertIn ("OK" , result .stdout )
490494
491495
496+ @support .requires_subprocess ()
492497class ErrorHandlingTests (unittest .TestCase ):
493498 """Tests for error handling during lazy import reification.
494499
@@ -645,6 +650,7 @@ def hello():
645650 self .assertIn ("Error" , result .stderr )
646651
647652
653+ @support .requires_subprocess ()
648654class GlobalsAndDictTests (unittest .TestCase ):
649655 """Tests for globals() and __dict__ behavior with lazy imports.
650656
@@ -814,6 +820,7 @@ def f():
814820 self .assertIn ("OK" , result .stdout )
815821
816822
823+ @support .requires_subprocess ()
817824class MultipleNameFromImportTests (unittest .TestCase ):
818825 """Tests for lazy from ... import with multiple names.
819826
@@ -894,6 +901,7 @@ def test_all_names_reified_after_all_accessed(self):
894901 self .assertIn ("OK" , result .stdout )
895902
896903
904+ @support .requires_subprocess ()
897905class SysLazyModulesTrackingTests (unittest .TestCase ):
898906 """Tests for sys.lazy_modules tracking behavior.
899907
@@ -946,6 +954,7 @@ def test_lazy_modules_is_per_interpreter(self):
946954 self .assertIsInstance (sys .lazy_modules , dict )
947955
948956
957+ @support .requires_subprocess ()
949958class CommandLineAndEnvVarTests (unittest .TestCase ):
950959 """Tests for command-line and environment variable control.
951960
@@ -1107,6 +1116,7 @@ def test_sys_set_lazy_imports_overrides_cli(self):
11071116 self .assertIn ("EAGER" , result .stdout )
11081117
11091118
1119+ @support .requires_subprocess ()
11101120class FilterFunctionSignatureTests (unittest .TestCase ):
11111121 """Tests for the filter function signature per PEP 810.
11121122
@@ -1226,6 +1236,7 @@ def test_lazy_import_inside_class_raises_syntax_error(self):
12261236 import test .test_lazy_import .data .badsyntax .lazy_class_body
12271237
12281238
1239+ @support .requires_subprocess ()
12291240class MixedLazyEagerImportTests (unittest .TestCase ):
12301241 """Tests for mixing lazy and eager imports of the same module.
12311242
@@ -1350,6 +1361,7 @@ def test_lazy_modules_makes_from_imports_lazy(self):
13501361 self .assertIn ("test.test_lazy_import.data.basic2" , sys .modules )
13511362
13521363
1364+ @support .requires_subprocess ()
13531365class ImportStateAtReificationTests (unittest .TestCase ):
13541366 """Tests for import system state at reification time.
13551367
@@ -1408,6 +1420,7 @@ def test_sys_path_at_reification_time_is_used(self):
14081420 self .assertIn ("OK" , result .stdout )
14091421
14101422
1423+ @support .requires_subprocess ()
14111424class ThreadSafetyTests (unittest .TestCase ):
14121425 """Tests for thread-safety of lazy imports."""
14131426
0 commit comments