]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-92265: set meta_path and path_hooks correctly in test_reload_namespace_changed...
authorFilipe Laíns <lains@archlinux.org>
Mon, 16 May 2022 23:05:47 +0000 (00:05 +0100)
committerGitHub <noreply@github.com>
Mon, 16 May 2022 23:05:47 +0000 (16:05 -0700)
Previously, we were blocking the frozen imports and forcing the source
version to be used, but we did not fix up sys.meta_path or
sys.path_hooks, causing the frozen importers to leak into the source
version of the test.

Lib/test/test_importlib/test_api.py

index 1f8f7c00bda53677083a58aa6a4e451629e61ff7..ddf80947b9df46e99020bb2216c2e31a63a1f436 100644 (file)
@@ -301,7 +301,8 @@ class ReloadTests:
         name = 'spam'
         with os_helper.temp_cwd(None) as cwd:
             with test_util.uncache('spam'):
-                with import_helper.DirsOnSysPath(cwd):
+                with test_util.import_state(path=[cwd]):
+                    self.init._bootstrap_external._install(self.init._bootstrap)
                     # Start as a namespace package.
                     self.init.invalidate_caches()
                     bad_path = os.path.join(cwd, name, '__init.py')