Skip to content

Commit

Permalink
pythongh-94217: Skip import tests when _testcapi is a builtin (python…
Browse files Browse the repository at this point in the history
…GH-94218)

(cherry picked from commit 0a40025)

Co-authored-by: Christian Heimes <[email protected]>
  • Loading branch information
tiran authored and miss-islington committed Jun 24, 2022
1 parent b140e5a commit 315d183
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lib/test/test_importlib/extension/test_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
machinery = util.import_importlib('importlib.machinery')

import unittest
import warnings
import sys


class FinderTests(abc.FinderTests):
Expand All @@ -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,
Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_importlib/extension/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 315d183

Please sign in to comment.