Skip to content

Add more independent tests at 3.13.3 #5701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 28 additions & 26 deletions Lib/test/test___all__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@
import sys
import types

try:
import _multiprocessing
except ModuleNotFoundError:
_multiprocessing = None


if support.check_sanitizer(address=True, memory=True):
# bpo-46633: test___all__ is skipped because importing some modules
# directly can trigger known problems with ASAN (like tk or crypt).
raise unittest.SkipTest("workaround ASAN build issues on loading tests "
"like tk or crypt")
SKIP_MODULES = frozenset((
# gh-90791: Tests involving libX11 can SEGFAULT on ASAN/MSAN builds.
# Skip modules, packages and tests using '_tkinter'.
'_tkinter',
'tkinter',
'test_tkinter',
'test_ttk',
'test_ttk_textonly',
'idlelib',
'test_idle',
))
else:
SKIP_MODULES = ()


class NoAll(RuntimeError):
Expand All @@ -27,17 +31,6 @@ class FailedImport(RuntimeError):

class AllTest(unittest.TestCase):

def setUp(self):
# concurrent.futures uses a __getattr__ hook. Its __all__ triggers
# import of a submodule, which fails when _multiprocessing is not
# available.
if _multiprocessing is None:
sys.modules["_multiprocessing"] = types.ModuleType("_multiprocessing")

def tearDown(self):
if _multiprocessing is None:
sys.modules.pop("_multiprocessing")

def check_all(self, modname):
names = {}
with warnings_helper.check_warnings(
Expand Down Expand Up @@ -83,16 +76,24 @@ def walk_modules(self, basedir, modpath):
for fn in sorted(os.listdir(basedir)):
path = os.path.join(basedir, fn)
if os.path.isdir(path):
if fn in SKIP_MODULES:
continue
pkg_init = os.path.join(path, '__init__.py')
if os.path.exists(pkg_init):
yield pkg_init, modpath + fn
for p, m in self.walk_modules(path, modpath + fn + "."):
yield p, m
continue
if not fn.endswith('.py') or fn == '__init__.py':

if fn == '__init__.py':
continue
yield path, modpath + fn[:-3]

if not fn.endswith('.py'):
continue
modname = fn.removesuffix('.py')
if modname in SKIP_MODULES:
continue
yield path, modpath + modname

# TODO: RUSTPYTHON
@unittest.expectedFailure
def test_all(self):
Expand All @@ -103,7 +104,8 @@ def test_all(self):
])

# In case _socket fails to build, make this test fail more gracefully
# than an AttributeError somewhere deep in CGIHTTPServer.
# than an AttributeError somewhere deep in concurrent.futures, email
# or unittest.
import _socket

ignored = []
Expand All @@ -120,14 +122,14 @@ def test_all(self):
if denied:
continue
if support.verbose:
print(modname)
print(f"Check {modname}", flush=True)
try:
# This heuristic speeds up the process by removing, de facto,
# most test modules (and avoiding the auto-executing ones).
with open(path, "rb") as f:
if b"__all__" not in f.read():
raise NoAll(modname)
self.check_all(modname)
self.check_all(modname)
except NoAll:
ignored.append(modname)
except FailedImport:
Expand Down
Loading
Loading