test__all__.py (#7037)

This commit is contained in:
Shahar Naveh authored and GitHub committed 2026-02-07 22:42:10 +09:00
1 parent f817ab8d07
commit 47f54f19c5
1 file changed
+6 -4
+6 -4
View File
@@ -3,7 +3,6 @@ from test import support
from test.support import warnings_helper
import os
import sys
import types
if support.check_sanitizer(address=True, memory=True):
@@ -38,6 +37,7 @@ class AllTest(unittest.TestCase):
(".* (module|package)", DeprecationWarning),
(".* (module|package)", PendingDeprecationWarning),
("", ResourceWarning),
("", SyntaxWarning),
quiet=True):
try:
exec("import %s" % modname, names)
@@ -53,6 +53,7 @@ class AllTest(unittest.TestCase):
with warnings_helper.check_warnings(
("", DeprecationWarning),
("", ResourceWarning),
("", SyntaxWarning),
quiet=True):
try:
exec("from %s import *" % modname, names)
@@ -71,6 +72,8 @@ class AllTest(unittest.TestCase):
all_set = set(all_list)
self.assertCountEqual(all_set, all_list, "in module {}".format(modname))
self.assertEqual(keys, all_set, "in module {}".format(modname))
# Verify __dir__ is non-empty and doesn't produce an error
self.assertTrue(dir(sys.modules[modname]))
def walk_modules(self, basedir, modpath):
for fn in sorted(os.listdir(basedir)):
@@ -94,8 +97,7 @@ class AllTest(unittest.TestCase):
continue
yield path, modpath + modname
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_all(self):
# List of denied modules and packages
denylist = set([
@@ -106,7 +108,7 @@ class AllTest(unittest.TestCase):
# In case _socket fails to build, make this test fail more gracefully
# than an AttributeError somewhere deep in concurrent.futures, email
# or unittest.
import _socket
import _socket # noqa: F401
ignored = []
failed_imports = []