Skip to content

Commit b9b3505

Browse files
committed
pythongh-108388: regrtest splits test_asyncio package
Currently, test_asyncio package is only splitted into sub-tests when using command "./python -m test". With this change, it's also splitted when passing it on the command line: "./python -m test test_asyncio".
1 parent 7a6cc3e commit b9b3505

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

Lib/test/libregrtest/main.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import unittest
1212
from test.libregrtest.cmdline import _parse_args
1313
from test.libregrtest.runtest import (
14-
findtests, runtest, get_abs_module, is_failed,
14+
findtests, split_test_packages, runtest, get_abs_module, is_failed,
1515
STDTESTS, NOTTESTS, PROGRESS_MIN_TIME,
1616
Passed, Failed, EnvChanged, Skipped, ResourceDenied, Interrupted,
1717
ChildError, DidNotRun)
@@ -263,7 +263,11 @@ def find_tests(self, tests):
263263
alltests = findtests(self.ns.testdir, stdtests, nottests)
264264

265265
if not self.ns.fromfile:
266-
self.selected = self.tests or self.ns.args or alltests
266+
self.selected = self.tests or self.ns.args
267+
if self.selected:
268+
self.selected = split_test_packages(self.selected)
269+
else:
270+
self.selected = alltests
267271
else:
268272
self.selected = self.tests
269273
if self.ns.single:

Lib/test/libregrtest/runtest.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,24 @@ def findtests(testdir=None, stdtests=STDTESTS, nottests=NOTTESTS, *, split_test_
178178
if mod in split_test_dirs:
179179
subdir = os.path.join(testdir, mod)
180180
mod = f"{base_mod or 'test'}.{mod}"
181-
tests.extend(findtests(subdir, [], nottests, split_test_dirs=split_test_dirs, base_mod=mod))
181+
tests.extend(findtests(subdir, [], nottests, split_test_dirs=(), base_mod=mod))
182182
elif ext in (".py", ""):
183183
tests.append(f"{base_mod}.{mod}" if base_mod else mod)
184184
return stdtests + sorted(tests)
185185

186186

187+
def split_test_packages(tests):
188+
testdir = findtestdir()
189+
splitted = []
190+
for name in tests:
191+
if name in SPLITTESTDIRS:
192+
subdir = os.path.join(testdir, name)
193+
splitted.extend(findtests(subdir, [], NOTTESTS, split_test_dirs=(), base_mod=name))
194+
else:
195+
splitted.append(name)
196+
return splitted
197+
198+
187199
def get_abs_module(ns: Namespace, test_name: str) -> str:
188200
if test_name.startswith('test.') or ns.testdir:
189201
return test_name

0 commit comments

Comments
 (0)