Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions django/test/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/test_runner/test_parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)
Expand Down