]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131647: fix 'sys.path_hooks is empty' warning in test_importlib (#131648)
authorThomas Grainger <tagrain@gmail.com>
Tue, 25 Mar 2025 17:16:15 +0000 (17:16 +0000)
committerGitHub <noreply@github.com>
Tue, 25 Mar 2025 17:16:15 +0000 (18:16 +0100)
Lib/test/test_importlib/import_/test_path.py

index 51ff6115e1281eda5f46431981f3cb3666a0f9c0..79e0bdca94c15cad049c4c19c1c4967e42952789 100644 (file)
@@ -158,11 +158,15 @@ class FinderTests:
     def test_permission_error_cwd(self):
         # gh-115911: Test that an unreadable CWD does not break imports, in
         # particular during early stages of interpreter startup.
+
+        def noop_hook(*args):
+            raise ImportError
+
         with (
             os_helper.temp_dir() as new_dir,
             os_helper.save_mode(new_dir),
             os_helper.change_cwd(new_dir),
-            util.import_state(path=['']),
+            util.import_state(path=[''], path_hooks=[noop_hook]),
         ):
             # chmod() is done here (inside the 'with' block) because the order
             # of teardown operations cannot be the reverse of setup order. See