mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Refs #34010 -- Made --debug-mode work for parallel tests using spawn.
Bug in 3b3f38b3b0
.
Thanks Kevin Renskers for the report.
This commit is contained in:
parent
4a910f3de3
commit
0f5b11eca0
@ -398,6 +398,7 @@ def _init_worker(
|
||||
serialized_contents=None,
|
||||
process_setup=None,
|
||||
process_setup_args=None,
|
||||
debug_mode=None,
|
||||
):
|
||||
"""
|
||||
Switch to databases dedicated to this worker.
|
||||
@ -420,7 +421,7 @@ def _init_worker(
|
||||
process_setup_args = ()
|
||||
process_setup(*process_setup_args)
|
||||
django.setup()
|
||||
setup_test_environment()
|
||||
setup_test_environment(debug=debug_mode)
|
||||
|
||||
for alias in connections:
|
||||
connection = connections[alias]
|
||||
@ -473,10 +474,13 @@ class ParallelTestSuite(unittest.TestSuite):
|
||||
run_subsuite = _run_subsuite
|
||||
runner_class = RemoteTestRunner
|
||||
|
||||
def __init__(self, subsuites, processes, failfast=False, buffer=False):
|
||||
def __init__(
|
||||
self, subsuites, processes, failfast=False, debug_mode=False, buffer=False
|
||||
):
|
||||
self.subsuites = subsuites
|
||||
self.processes = processes
|
||||
self.failfast = failfast
|
||||
self.debug_mode = debug_mode
|
||||
self.buffer = buffer
|
||||
self.initial_settings = None
|
||||
self.serialized_contents = None
|
||||
@ -508,6 +512,7 @@ class ParallelTestSuite(unittest.TestSuite):
|
||||
self.serialized_contents,
|
||||
self.process_setup.__func__,
|
||||
self.process_setup_args,
|
||||
self.debug_mode,
|
||||
],
|
||||
)
|
||||
args = [
|
||||
@ -933,6 +938,7 @@ class DiscoverRunner:
|
||||
subsuites,
|
||||
processes,
|
||||
self.failfast,
|
||||
self.debug_mode,
|
||||
self.buffer,
|
||||
)
|
||||
return suite
|
||||
|
@ -31,3 +31,7 @@ Bugfixes
|
||||
* Fixed a regression in Django 4.1 where the app registry was not populated
|
||||
when running parallel tests with the ``multiprocessing`` start method
|
||||
``spawn`` (:ticket:`34010`).
|
||||
|
||||
* Fixed a regression in Django 4.1 where the ``--debug-mode`` argument to
|
||||
``test`` did not work when running parallel tests with the
|
||||
``multiprocessing`` start method ``spawn`` (:ticket:`34010`).
|
||||
|
@ -713,7 +713,9 @@ class TestRunnerInitializerTests(SimpleTestCase):
|
||||
runner = self.test_runner(**kwargs)
|
||||
return runner.run(suite)
|
||||
|
||||
runner = StubTestRunner(verbosity=0, interactive=False, parallel=2)
|
||||
runner = StubTestRunner(
|
||||
verbosity=0, interactive=False, parallel=2, debug_mode=True
|
||||
)
|
||||
with self.assertRaisesMessage(Exception, "multiprocessing.Pool()"):
|
||||
runner.run_tests(
|
||||
[
|
||||
@ -723,6 +725,9 @@ class TestRunnerInitializerTests(SimpleTestCase):
|
||||
)
|
||||
# Initializer must be a function.
|
||||
self.assertIs(mocked_pool.call_args.kwargs["initializer"], _init_worker)
|
||||
initargs = mocked_pool.call_args.kwargs["initargs"]
|
||||
self.assertEqual(len(initargs), 6)
|
||||
self.assertEqual(initargs[5], True) # debug_mode
|
||||
|
||||
|
||||
class Ticket17477RegressionTests(AdminScriptTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user