Skip to content

Commit 5038d69

Browse files
BonaFideITcarltongibson
authored andcommitted
Fix live server setup when test DB name not set.
Closes #2176.
1 parent f17a8fe commit 5038d69

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

channels/testing/live.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from django.contrib.staticfiles.handlers import ASGIStaticFilesHandler
55
from django.core.exceptions import ImproperlyConfigured
66
from django.db import connections
7+
from django.db.backends.base.creation import TEST_DATABASE_PREFIX
78
from django.test.testcases import TransactionTestCase
89
from django.test.utils import modify_settings
910

@@ -22,6 +23,8 @@ def set_database_connection():
2223
from django.conf import settings
2324

2425
test_db_name = settings.DATABASES["default"]["TEST"]["NAME"]
26+
if not test_db_name:
27+
test_db_name = TEST_DATABASE_PREFIX + settings.DATABASES["default"]["NAME"]
2528
settings.DATABASES["default"]["NAME"] = test_db_name
2629

2730

0 commit comments

Comments
 (0)