From 548209e620b3ca34396a360453f07c8dbb8aa6c7 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 21 Oct 2025 21:11:44 +0200 Subject: [PATCH 1/2] Made RemoteTestResultTest.test_pickle_errors_detection() compatible with tblib 3.2+. tblib 3.2+ makes exception subclasses with __init__() and the default __reduce__() picklable. This broke the test for RemoteTestResult._confirm_picklable(), which expects a specific exception to fail unpickling. https://github.com/ionelmc/python-tblib/blob/master/CHANGELOG.rst#320-2025-10-21 This fix defines ExceptionThatFailsUnpickling.__reduce__() in a way that pickle.dumps(obj) succeeds, but pickle.loads(pickle.dumps(obj)) raises TypeError. Refs #27301. This preserves the intent of the regression test from 52188a5ca6bafea0a66f17baacb315d61c7b99cd without skipping it. --- tests/test_runner/test_parallel.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_runner/test_parallel.py b/tests/test_runner/test_parallel.py index fa129da76800..32cc971d305d 100644 --- a/tests/test_runner/test_parallel.py +++ b/tests/test_runner/test_parallel.py @@ -32,6 +32,12 @@ class ExceptionThatFailsUnpickling(Exception): def __init__(self, arg): super().__init__() + def __reduce__(self): + # tblib 3.2+ makes exception subclasses picklable by default. + # Return (cls, ()) so the constructor fails on unpickle, preserving + # the needed behavior for test_pickle_errors_detection. + return (self.__class__, ()) + class ParallelTestRunnerTest(SimpleTestCase): """ @@ -170,6 +176,8 @@ def test_pickle_errors_detection(self): result = RemoteTestResult() result._confirm_picklable(picklable_error) + # The exception can be pickled but not unpickled. + pickle.dumps(not_unpicklable_error) msg = "__init__() missing 1 required positional argument" with self.assertRaisesMessage(TypeError, msg): result._confirm_picklable(not_unpicklable_error) From b6c9246d0a3ef5f9a40b15cc289b495351eae109 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Tue, 21 Oct 2025 13:10:52 -0400 Subject: [PATCH 2/2] Fixed #36677 -- Fixed scheduling of system checks in ParallelTestSuite workers. Running system checks in workers must happen after database aliases are set up. Regression in 606fc352799e372928fa2c978ab99f0fb6d6017c. --- django/test/runner.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/django/test/runner.py b/django/test/runner.py index 25089a6db1b1..41c9dbd10ca9 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -463,9 +463,6 @@ def _init_worker( process_setup(*process_setup_args) django.setup() setup_test_environment(debug=debug_mode) - call_command( - "check", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases - ) db_aliases = used_aliases if used_aliases is not None else connections for alias in db_aliases: @@ -477,6 +474,11 @@ def _init_worker( connection._test_serialized_contents = value connection.creation.setup_worker_connection(_worker_id) + if is_spawn_or_forkserver: + call_command( + "check", stdout=io.StringIO(), stderr=io.StringIO(), databases=used_aliases + ) + def _run_subsuite(args): """