mirror of
https://github.com/python/cpython.git
synced 2024-11-21 12:59:38 +01:00
gh-108388: Split test_multiprocessing_spawn (#108396)
Split test_multiprocessing_fork, test_multiprocessing_forkserver and test_multiprocessing_spawn into test packages. Each package is made of 4 sub-tests: processes, threads, manager and misc. It allows running more tests in parallel and so reduce the total test duration.
This commit is contained in:
parent
174e9da083
commit
aa9a359ca2
@ -6126,7 +6126,8 @@ class ThreadsMixin(BaseMixin):
|
||||
# Functions used to create test cases from the base ones in this module
|
||||
#
|
||||
|
||||
def install_tests_in_module_dict(remote_globs, start_method):
|
||||
def install_tests_in_module_dict(remote_globs, start_method,
|
||||
only_type=None, exclude_types=False):
|
||||
__module__ = remote_globs['__name__']
|
||||
local_globs = globals()
|
||||
ALL_TYPES = {'processes', 'threads', 'manager'}
|
||||
@ -6139,6 +6140,10 @@ def install_tests_in_module_dict(remote_globs, start_method):
|
||||
continue
|
||||
assert set(base.ALLOWED_TYPES) <= ALL_TYPES, base.ALLOWED_TYPES
|
||||
for type_ in base.ALLOWED_TYPES:
|
||||
if only_type and type_ != only_type:
|
||||
continue
|
||||
if exclude_types:
|
||||
continue
|
||||
newname = 'With' + type_.capitalize() + name[1:]
|
||||
Mixin = local_globs[type_.capitalize() + 'Mixin']
|
||||
class Temp(base, Mixin, unittest.TestCase):
|
||||
@ -6149,6 +6154,9 @@ def install_tests_in_module_dict(remote_globs, start_method):
|
||||
Temp.__module__ = __module__
|
||||
remote_globs[newname] = Temp
|
||||
elif issubclass(base, unittest.TestCase):
|
||||
if only_type:
|
||||
continue
|
||||
|
||||
class Temp(base, object):
|
||||
pass
|
||||
Temp.__name__ = Temp.__qualname__ = name
|
||||
|
@ -132,6 +132,9 @@ PROGRESS_MIN_TIME = 30.0 # seconds
|
||||
|
||||
SPLITTESTDIRS = {
|
||||
"test_asyncio",
|
||||
"test_multiprocessing_fork",
|
||||
"test_multiprocessing_forkserver",
|
||||
"test_multiprocessing_spawn",
|
||||
}
|
||||
|
||||
# Storage of uncollectable objects
|
||||
|
@ -1,7 +1,6 @@
|
||||
import unittest
|
||||
import test._test_multiprocessing
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
import unittest
|
||||
from test import support
|
||||
|
||||
if support.PGO:
|
||||
@ -13,7 +12,5 @@ if sys.platform == "win32":
|
||||
if sys.platform == 'darwin':
|
||||
raise unittest.SkipTest("test may crash on macOS (bpo-33725)")
|
||||
|
||||
test._test_multiprocessing.install_tests_in_module_dict(globals(), 'fork')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
def load_tests(*args):
|
||||
return support.load_package_tests(os.path.dirname(__file__), *args)
|
7
Lib/test/test_multiprocessing_fork/test_manager.py
Normal file
7
Lib/test/test_multiprocessing_fork/test_manager.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'fork', only_type="manager")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_fork/test_misc.py
Normal file
7
Lib/test/test_multiprocessing_fork/test_misc.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'fork', exclude_types=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_fork/test_processes.py
Normal file
7
Lib/test/test_multiprocessing_fork/test_processes.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'fork', only_type="processes")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_fork/test_threads.py
Normal file
7
Lib/test/test_multiprocessing_fork/test_threads.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'fork', only_type="threads")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -1,7 +1,6 @@
|
||||
import unittest
|
||||
import test._test_multiprocessing
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
import unittest
|
||||
from test import support
|
||||
|
||||
if support.PGO:
|
||||
@ -10,7 +9,5 @@ if support.PGO:
|
||||
if sys.platform == "win32":
|
||||
raise unittest.SkipTest("forkserver is not available on Windows")
|
||||
|
||||
test._test_multiprocessing.install_tests_in_module_dict(globals(), 'forkserver')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
def load_tests(*args):
|
||||
return support.load_package_tests(os.path.dirname(__file__), *args)
|
7
Lib/test/test_multiprocessing_forkserver/test_manager.py
Normal file
7
Lib/test/test_multiprocessing_forkserver/test_manager.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'forkserver', only_type="manager")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_forkserver/test_misc.py
Normal file
7
Lib/test/test_multiprocessing_forkserver/test_misc.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'forkserver', exclude_types=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'forkserver', only_type="processes")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_forkserver/test_threads.py
Normal file
7
Lib/test/test_multiprocessing_forkserver/test_threads.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'forkserver', only_type="threads")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -1,12 +0,0 @@
|
||||
import unittest
|
||||
import test._test_multiprocessing
|
||||
|
||||
from test import support
|
||||
|
||||
if support.PGO:
|
||||
raise unittest.SkipTest("test is not helpful for PGO")
|
||||
|
||||
test._test_multiprocessing.install_tests_in_module_dict(globals(), 'spawn')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
9
Lib/test/test_multiprocessing_spawn/__init__.py
Normal file
9
Lib/test/test_multiprocessing_spawn/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
import os.path
|
||||
import unittest
|
||||
from test import support
|
||||
|
||||
if support.PGO:
|
||||
raise unittest.SkipTest("test is not helpful for PGO")
|
||||
|
||||
def load_tests(*args):
|
||||
return support.load_package_tests(os.path.dirname(__file__), *args)
|
7
Lib/test/test_multiprocessing_spawn/test_manager.py
Normal file
7
Lib/test/test_multiprocessing_spawn/test_manager.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'spawn', only_type="manager")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_spawn/test_misc.py
Normal file
7
Lib/test/test_multiprocessing_spawn/test_misc.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'spawn', exclude_types=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_spawn/test_processes.py
Normal file
7
Lib/test/test_multiprocessing_spawn/test_processes.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'spawn', only_type="processes")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
7
Lib/test/test_multiprocessing_spawn/test_threads.py
Normal file
7
Lib/test/test_multiprocessing_spawn/test_threads.py
Normal file
@ -0,0 +1,7 @@
|
||||
import unittest
|
||||
from test._test_multiprocessing import install_tests_in_module_dict
|
||||
|
||||
install_tests_in_module_dict(globals(), 'spawn', only_type="threads")
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
@ -0,0 +1,4 @@
|
||||
Split test_multiprocessing_fork, test_multiprocessing_forkserver and
|
||||
test_multiprocessing_spawn into test packages. Each package is made of 4
|
||||
sub-tests: processes, threads, manager and misc. It allows running more tests
|
||||
in parallel and so reduce the total test duration. Patch by Victor Stinner.
|
Loading…
Reference in New Issue
Block a user