diff options
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/commands/testserver.py | 2 | ||||
| -rw-r--r-- | django/db/backends/base/creation.py | 20 | ||||
| -rw-r--r-- | django/test/utils.py | 1 |
3 files changed, 18 insertions, 5 deletions
diff --git a/django/core/management/commands/testserver.py b/django/core/management/commands/testserver.py index a8a03764c9..ee472794f7 100644 --- a/django/core/management/commands/testserver.py +++ b/django/core/management/commands/testserver.py @@ -41,7 +41,7 @@ class Command(BaseCommand): # Create a test database. db_name = connection.creation.create_test_db( - verbosity=verbosity, autoclobber=not interactive, serialize=False + verbosity=verbosity, autoclobber=not interactive ) # Import the fixture data into the test database. 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) diff --git a/django/test/utils.py b/django/test/utils.py index a4e80b0b53..78bbb0cf65 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -205,7 +205,6 @@ def setup_databases( verbosity=verbosity, autoclobber=not interactive, keepdb=keepdb, - serialize=False, ) if serialized_aliases is None or alias in serialized_aliases: serialize_connections.append(connection) |
