From 84dee32f3bf7bad1287499887e3d67eddbf6118c Mon Sep 17 00:00:00 2001 From: Bona Fide IT GmbH <137388433+BonaFideIT@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:15:12 +0200 Subject: [PATCH 1/2] Fix test database name generation --- channels/testing/live.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/channels/testing/live.py b/channels/testing/live.py index aa1a7880..152a7414 100644 --- a/channels/testing/live.py +++ b/channels/testing/live.py @@ -1,3 +1,4 @@ +import multiprocessing from functools import partial from daphne.testing import DaphneProcess @@ -22,8 +23,11 @@ def make_application(*, static_wrapper): def set_database_connection(): from django.conf import settings + def set_database_connection(): + from django.conf import settings + test_db_name = settings.DATABASES["default"]["TEST"]["NAME"] - if not test_db_name: + if not test_db_name and multiprocessing.get_start_method() == "spawn": test_db_name = TEST_DATABASE_PREFIX + settings.DATABASES["default"]["NAME"] settings.DATABASES["default"]["NAME"] = test_db_name From 21b36cf25fe37fcb47b129973cd669985657d9d2 Mon Sep 17 00:00:00 2001 From: Bona Fide IT GmbH <137388433+BonaFideIT@users.noreply.github.com> Date: Wed, 24 Sep 2025 08:18:22 +0200 Subject: [PATCH 2/2] Fix code --- channels/testing/live.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/channels/testing/live.py b/channels/testing/live.py index 152a7414..2565edac 100644 --- a/channels/testing/live.py +++ b/channels/testing/live.py @@ -23,9 +23,6 @@ def make_application(*, static_wrapper): def set_database_connection(): from django.conf import settings - def set_database_connection(): - from django.conf import settings - test_db_name = settings.DATABASES["default"]["TEST"]["NAME"] if not test_db_name and multiprocessing.get_start_method() == "spawn": test_db_name = TEST_DATABASE_PREFIX + settings.DATABASES["default"]["NAME"]