summaryrefslogtreecommitdiff
path: root/django/db/backends/base/creation.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/db/backends/base/creation.py')
-rw-r--r--django/db/backends/base/creation.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/django/db/backends/base/creation.py b/django/db/backends/base/creation.py
index 6856fdb596..845235bc72 100644
--- a/django/db/backends/base/creation.py
+++ b/django/db/backends/base/creation.py
@@ -1,5 +1,6 @@
import os
import sys
+import warnings
from io import StringIO
from django.apps import apps
@@ -7,6 +8,7 @@ from django.conf import settings
from django.core import serializers
from django.db import router
from django.db.transaction import atomic
+from django.utils.deprecation import RemovedInDjango70Warning
from django.utils.module_loading import import_string
# The prefix to put on the default database name when creating
@@ -29,8 +31,10 @@ class BaseDatabaseCreation:
def log(self, msg):
sys.stderr.write(msg + os.linesep)
+ # RemovedInDjango70Warning: When the deprecation ends, replace with:
+ # def create_test_db(self, verbosity=1, autoclobber=False, keepdb=False):
def create_test_db(
- self, verbosity=1, autoclobber=False, serialize=True, keepdb=False
+ self, verbosity=1, autoclobber=False, serialize=None, keepdb=False
):
"""
Create a test database, prompting the user for confirmation if the
@@ -90,8 +94,18 @@ class BaseDatabaseCreation:
# and store it on the connection. This slightly horrific process is so people
# who are testing on databases without transactions or who are using
# a TransactionTestCase still get a clean database on every test run.
- if serialize:
- self.connection._test_serialized_contents = self.serialize_db_to_string()
+ if serialize is not None:
+ warnings.warn(
+ "DatabaseCreation.create_test_db(serialize) is deprecated. Call "
+ "DatabaseCreation.serialize_test_db() once all test databases are set "
+ "up instead if you need fixtures persistence between tests.",
+ stacklevel=2,
+ category=RemovedInDjango70Warning,
+ )
+ if serialize:
+ self.connection._test_serialized_contents = (
+ self.serialize_db_to_string()
+ )
call_command("createcachetable", database=self.connection.alias)