diff --git a/Lib/test/test_importlib/extension/test_finder.py b/Lib/test/test_importlib/extension/test_finder.py index b6663a44845502..1d5b6e7a5de94b 100644 --- a/Lib/test/test_importlib/extension/test_finder.py +++ b/Lib/test/test_importlib/extension/test_finder.py @@ -3,7 +3,7 @@ machinery = util.import_importlib('importlib.machinery') import unittest -import warnings +import sys class FinderTests(abc.FinderTests): @@ -13,6 +13,10 @@ class FinderTests(abc.FinderTests): def setUp(self): if not self.machinery.EXTENSION_SUFFIXES: raise unittest.SkipTest("Requires dynamic loading support.") + if util.EXTENSIONS.name in sys.builtin_module_names: + raise unittest.SkipTest( + f"{util.EXTENSIONS.name} is a builtin module" + ) def find_spec(self, fullname): importer = self.machinery.FileFinder(util.EXTENSIONS.path, diff --git a/Lib/test/test_importlib/extension/test_loader.py b/Lib/test/test_importlib/extension/test_loader.py index 5080009bee32ee..8570c6bc90cd07 100644 --- a/Lib/test/test_importlib/extension/test_loader.py +++ b/Lib/test/test_importlib/extension/test_loader.py @@ -20,6 +20,10 @@ class LoaderTests(abc.LoaderTests): def setUp(self): if not self.machinery.EXTENSION_SUFFIXES: raise unittest.SkipTest("Requires dynamic loading support.") + if util.EXTENSIONS.name in sys.builtin_module_names: + raise unittest.SkipTest( + f"{util.EXTENSIONS.name} is a builtin module" + ) self.loader = self.machinery.ExtensionFileLoader(util.EXTENSIONS.name, util.EXTENSIONS.file_path) @@ -97,6 +101,10 @@ def setUp(self): if not self.machinery.EXTENSION_SUFFIXES: raise unittest.SkipTest("Requires dynamic loading support.") self.name = '_testmultiphase' + if self.name in sys.builtin_module_names: + raise unittest.SkipTest( + f"{self.name} is a builtin module" + ) finder = self.machinery.FileFinder(None) self.spec = importlib.util.find_spec(self.name) assert self.spec