5
5
import sys
6
6
import types
7
7
8
- try :
9
- import _multiprocessing
10
- except ModuleNotFoundError :
11
- _multiprocessing = None
12
-
13
8
14
9
if support .check_sanitizer (address = True , memory = True ):
15
- # bpo-46633: test___all__ is skipped because importing some modules
16
- # directly can trigger known problems with ASAN (like tk or crypt).
17
- raise unittest .SkipTest ("workaround ASAN build issues on loading tests "
18
- "like tk or crypt" )
10
+ SKIP_MODULES = frozenset ((
11
+ # gh-90791: Tests involving libX11 can SEGFAULT on ASAN/MSAN builds.
12
+ # Skip modules, packages and tests using '_tkinter'.
13
+ '_tkinter' ,
14
+ 'tkinter' ,
15
+ 'test_tkinter' ,
16
+ 'test_ttk' ,
17
+ 'test_ttk_textonly' ,
18
+ 'idlelib' ,
19
+ 'test_idle' ,
20
+ ))
21
+ else :
22
+ SKIP_MODULES = ()
19
23
20
24
21
25
class NoAll (RuntimeError ):
@@ -27,17 +31,6 @@ class FailedImport(RuntimeError):
27
31
28
32
class AllTest (unittest .TestCase ):
29
33
30
- def setUp (self ):
31
- # concurrent.futures uses a __getattr__ hook. Its __all__ triggers
32
- # import of a submodule, which fails when _multiprocessing is not
33
- # available.
34
- if _multiprocessing is None :
35
- sys .modules ["_multiprocessing" ] = types .ModuleType ("_multiprocessing" )
36
-
37
- def tearDown (self ):
38
- if _multiprocessing is None :
39
- sys .modules .pop ("_multiprocessing" )
40
-
41
34
def check_all (self , modname ):
42
35
names = {}
43
36
with warnings_helper .check_warnings (
@@ -83,16 +76,24 @@ def walk_modules(self, basedir, modpath):
83
76
for fn in sorted (os .listdir (basedir )):
84
77
path = os .path .join (basedir , fn )
85
78
if os .path .isdir (path ):
79
+ if fn in SKIP_MODULES :
80
+ continue
86
81
pkg_init = os .path .join (path , '__init__.py' )
87
82
if os .path .exists (pkg_init ):
88
83
yield pkg_init , modpath + fn
89
84
for p , m in self .walk_modules (path , modpath + fn + "." ):
90
85
yield p , m
91
86
continue
92
- if not fn .endswith ('.py' ) or fn == '__init__.py' :
87
+
88
+ if fn == '__init__.py' :
93
89
continue
94
- yield path , modpath + fn [:- 3 ]
95
-
90
+ if not fn .endswith ('.py' ):
91
+ continue
92
+ modname = fn .removesuffix ('.py' )
93
+ if modname in SKIP_MODULES :
94
+ continue
95
+ yield path , modpath + modname
96
+
96
97
# TODO: RUSTPYTHON
97
98
@unittest .expectedFailure
98
99
def test_all (self ):
@@ -103,7 +104,8 @@ def test_all(self):
103
104
])
104
105
105
106
# In case _socket fails to build, make this test fail more gracefully
106
- # than an AttributeError somewhere deep in CGIHTTPServer.
107
+ # than an AttributeError somewhere deep in concurrent.futures, email
108
+ # or unittest.
107
109
import _socket
108
110
109
111
ignored = []
@@ -120,14 +122,14 @@ def test_all(self):
120
122
if denied :
121
123
continue
122
124
if support .verbose :
123
- print (modname )
125
+ print (f"Check { modname } " , flush = True )
124
126
try :
125
12
6D47
7
# This heuristic speeds up the process by removing, de facto,
126
128
# most test modules (and avoiding the auto-executing ones).
127
129
with open (path , "rb" ) as f :
128
130
if b"__all__" not in f .read ():
129
131
raise NoAll (modname )
130
- self .check_all (modname )
132
+ self .check_all (modname )
131
133
except NoAll :
132
134
ignored .append (modname )
133
135
except FailedImport :
0 commit comments