@@ -143,6 +143,15 @@ def __str__(self) -> str:
143
143
# set of tests that we don't want to be executed when using regrtest
144
144
NOTTESTS = set ()
145
145
146
+ #If these test directories are encountered recurse into them and treat each
147
+ # test_ .py or dir as a separate test module. This can increase parallelism.
148
+ # Beware this can't generally be done for any directory with sub-tests as the
149
+ # __init__.py may do things which alter what tests are to be run.
150
+
151
+ SPLITTESTDIRS = {
152
+ "test_asyncio" ,
153
+ "test_compiler" ,
154
+ }
146
155
147
156
# Storage of uncollectable objects
148
157
FOUND_GARBAGE = []
@@ -158,16 +167,24 @@ def findtestdir(path=None):
158
167
return path or os .path .dirname (os .path .dirname (__file__ )) or os .curdir
159
168
160
169
161
- def findtests (testdir = None , stdtests = STDTESTS , nottests = NOTTESTS ):
170
+ def findtests (testdir = None , stdtests = STDTESTS , nottests = NOTTESTS , splittestdirs = SPLITTESTDIRS , base_mod = "" ):
162
171
"""Return a list of all applicable test modules."""
163
172
testdir = findtestdir (testdir )
164
173
names = os .listdir (testdir )
165
174
tests = []
166
175
others = set (stdtests ) | nottests
167
176
for name in names :
168
177
mod , ext = os .path .splitext (name )
169
- if mod [:5 ] == "test_" and ext in (".py" , "" ) and mod not in others :
170
- tests .append (mod )
178
+ if mod [:5 ] == "test_" and mod not in others :
179
+ if mod in splittestdirs :
180
+ subdir = os .path .join (testdir , mod )
181
+ if len (base_mod ):
182
+ mod = f"{ base_mod } .{ mod } "
183
+ else :
184
+ mod = f"test.{ mod } "
185
+ tests .extend (findtests (subdir , [], nottests , splittestdirs , mod ))
186
+ elif ext in (".py" , "" ):
187
+ tests .append (f"{ base_mod } .{ mod } " if len (base_mod ) else mod )
171
188
return stdtests + sorted (tests )
172
189
173
190
0 commit comments