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,
|
serialized_contents=None,
|
||||||
process_setup=None,
|
process_setup=None,
|
||||||
process_setup_args=None,
|
process_setup_args=None,
|
||||||
|
debug_mode=None,
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
Switch to databases dedicated to this worker.
|
Switch to databases dedicated to this worker.
|
||||||
|
@ -420,7 +421,7 @@ def _init_worker(
|
||||||
process_setup_args = ()
|
process_setup_args = ()
|
||||||
process_setup(*process_setup_args)
|
process_setup(*process_setup_args)
|
||||||
django.setup()
|
django.setup()
|
||||||
setup_test_environment()
|
setup_test_environment(debug=debug_mode)
|
||||||
|
|
||||||
for alias in connections:
|
for alias in connections:
|
||||||
connection = connections[alias]
|
connection = connections[alias]
|
||||||
|
@ -473,10 +474,13 @@ class ParallelTestSuite(unittest.TestSuite):
|
||||||
run_subsuite = _run_subsuite
|
run_subsuite = _run_subsuite
|
||||||
runner_class = RemoteTestRunner
|
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.subsuites = subsuites
|
||||||
self.processes = processes
|
self.processes = processes
|
||||||
self.failfast = failfast
|
self.failfast = failfast
|
||||||
|
self.debug_mode = debug_mode
|
||||||
self.buffer = buffer
|
self.buffer = buffer
|
||||||
self.initial_settings = None
|
self.initial_settings = None
|
||||||
self.serialized_contents = None
|
self.serialized_contents = None
|
||||||
|
@ -508,6 +512,7 @@ class ParallelTestSuite(unittest.TestSuite):
|
||||||
self.serialized_contents,
|
self.serialized_contents,
|
||||||
self.process_setup.__func__,
|
self.process_setup.__func__,
|
||||||
self.process_setup_args,
|
self.process_setup_args,
|
||||||
|
self.debug_mode,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
args = [
|
args = [
|
||||||
|
@ -933,6 +938,7 @@ class DiscoverRunner:
|
||||||
subsuites,
|
subsuites,
|
||||||
processes,
|
processes,
|
||||||
self.failfast,
|
self.failfast,
|
||||||
|
self.debug_mode,
|
||||||
self.buffer,
|
self.buffer,
|
||||||
)
|
)
|
||||||
return suite
|
return suite
|
||||||
|
|
|
@ -31,3 +31,7 @@ Bugfixes
|
||||||
* Fixed a regression in Django 4.1 where the app registry was not populated
|
* Fixed a regression in Django 4.1 where the app registry was not populated
|
||||||
when running parallel tests with the ``multiprocessing`` start method
|
when running parallel tests with the ``multiprocessing`` start method
|
||||||
``spawn`` (:ticket:`34010`).
|
``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)
|
runner = self.test_runner(**kwargs)
|
||||||
return runner.run(suite)
|
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()"):
|
with self.assertRaisesMessage(Exception, "multiprocessing.Pool()"):
|
||||||
runner.run_tests(
|
runner.run_tests(
|
||||||
[
|
[
|
||||||
|
@ -723,6 +725,9 @@ class TestRunnerInitializerTests(SimpleTestCase):
|
||||||
)
|
)
|
||||||
# Initializer must be a function.
|
# Initializer must be a function.
|
||||||
self.assertIs(mocked_pool.call_args.kwargs["initializer"], _init_worker)
|
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):
|
class Ticket17477RegressionTests(AdminScriptTestCase):
|
||||||
|
|
Loading…
Reference in New Issue