mirror of
https://github.com/django/django.git
synced 2024-12-22 09:05:43 +00:00
Refs #32446 -- Removed SERIALIZE test database setting per deprecation timeline.
This commit is contained in:
parent
490cccbe7e
commit
6c0539ed7c
@ -26,7 +26,6 @@ from django.db.models.options import Options
|
||||
from django.template import Template
|
||||
from django.test.signals import template_rendered
|
||||
from django.urls import get_script_prefix, set_script_prefix
|
||||
from django.utils.deprecation import RemovedInDjango50Warning
|
||||
from django.utils.translation import deactivate
|
||||
|
||||
try:
|
||||
@ -198,26 +197,9 @@ def setup_databases(
|
||||
if first_alias is None:
|
||||
first_alias = alias
|
||||
with time_keeper.timed(" Creating '%s'" % alias):
|
||||
# RemovedInDjango50Warning: when the deprecation ends,
|
||||
# replace with:
|
||||
# serialize_alias = (
|
||||
# serialized_aliases is None
|
||||
# or alias in serialized_aliases
|
||||
# )
|
||||
try:
|
||||
serialize_alias = connection.settings_dict["TEST"]["SERIALIZE"]
|
||||
except KeyError:
|
||||
serialize_alias = (
|
||||
serialized_aliases is None or alias in serialized_aliases
|
||||
)
|
||||
else:
|
||||
warnings.warn(
|
||||
"The SERIALIZE test database setting is "
|
||||
"deprecated as it can be inferred from the "
|
||||
"TestCase/TransactionTestCase.databases that "
|
||||
"enable the serialized_rollback feature.",
|
||||
category=RemovedInDjango50Warning,
|
||||
)
|
||||
serialize_alias = (
|
||||
serialized_aliases is None or alias in serialized_aliases
|
||||
)
|
||||
connection.creation.create_test_db(
|
||||
verbosity=verbosity,
|
||||
autoclobber=not interactive,
|
||||
|
@ -849,23 +849,6 @@ test database will use the name ``'test_' + DATABASE_NAME``.
|
||||
|
||||
See :ref:`the-test-database`.
|
||||
|
||||
.. setting:: TEST_SERIALIZE
|
||||
|
||||
``SERIALIZE``
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
Boolean value to control whether or not the default test runner serializes the
|
||||
database into an in-memory JSON string before running tests (used to restore
|
||||
the database state between tests if you don't have transactions). You can set
|
||||
this to ``False`` to speed up creation time if you don't have any test classes
|
||||
with :ref:`serialized_rollback=True <test-case-serialized-rollback>`.
|
||||
|
||||
.. deprecated:: 4.0
|
||||
|
||||
This setting is deprecated as it can be inferred from the
|
||||
:attr:`~django.test.TestCase.databases` with the
|
||||
:ref:`serialized_rollback <test-case-serialized-rollback>` option enabled.
|
||||
|
||||
.. setting:: TEST_TEMPLATE
|
||||
|
||||
``TEMPLATE``
|
||||
|
@ -71,8 +71,8 @@ Bugfixes
|
||||
* Made ``migrations.RunSQL`` no longer require percent sign escaping. This is
|
||||
now consistent with ``cursor.execute()`` (:ticket:`23426`).
|
||||
|
||||
* Made the :setting:`SERIALIZE <TEST_SERIALIZE>` entry in the
|
||||
:setting:`TEST <DATABASE-TEST>` dictionary usable (:ticket:`23421`).
|
||||
* Made the ``SERIALIZE`` entry in the :setting:`TEST <DATABASE-TEST>`
|
||||
dictionary usable (:ticket:`23421`).
|
||||
|
||||
* Fixed bug in migrations that prevented foreign key constraints to unmanaged
|
||||
models with a custom primary key (:ticket:`23415`).
|
||||
|
@ -255,7 +255,7 @@ in Django 5.0.
|
||||
See :ref:`deprecated-features-4.0` for details on these changes, including how
|
||||
to remove usage of these features.
|
||||
|
||||
* ...
|
||||
* The ``SERIALIZE`` test setting is removed.
|
||||
|
||||
See :ref:`deprecated-features-4.1` for details on these changes, including how
|
||||
to remove usage of these features.
|
||||
|
@ -829,10 +829,6 @@ can be useful during testing.
|
||||
``False`` to speed up creation time if you don't have any test classes
|
||||
with :ref:`serialized_rollback=True <test-case-serialized-rollback>`.
|
||||
|
||||
If you are using the default test runner, you can control this with the
|
||||
the :setting:`SERIALIZE <TEST_SERIALIZE>` entry in the :setting:`TEST
|
||||
<DATABASE-TEST>` dictionary.
|
||||
|
||||
``keepdb`` determines if the test run should use an existing
|
||||
database, or create a new one. If ``True``, the existing
|
||||
database will be used, or created if not present. If ``False``,
|
||||
|
@ -819,7 +819,7 @@ class AliasedDefaultTestSetupTest(unittest.TestCase):
|
||||
runner_instance.teardown_databases(old_config)
|
||||
|
||||
|
||||
class SetupDatabasesTests(SimpleTestCase):
|
||||
class SetupDatabasesTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.runner_instance = DiscoverRunner(verbosity=0)
|
||||
|
||||
@ -912,30 +912,6 @@ class SetupDatabasesTests(SimpleTestCase):
|
||||
verbosity=0, autoclobber=False, serialize=True, keepdb=False
|
||||
)
|
||||
|
||||
def test_serialized_off(self):
|
||||
tested_connections = db.ConnectionHandler(
|
||||
{
|
||||
"default": {
|
||||
"ENGINE": "django.db.backends.dummy",
|
||||
"TEST": {"SERIALIZE": False},
|
||||
},
|
||||
}
|
||||
)
|
||||
msg = (
|
||||
"The SERIALIZE test database setting is deprecated as it can be "
|
||||
"inferred from the TestCase/TransactionTestCase.databases that "
|
||||
"enable the serialized_rollback feature."
|
||||
)
|
||||
with mock.patch(
|
||||
"django.db.backends.dummy.base.DatabaseWrapper.creation_class"
|
||||
) as mocked_db_creation:
|
||||
with mock.patch("django.test.utils.connections", new=tested_connections):
|
||||
with self.assertWarnsMessage(RemovedInDjango50Warning, msg):
|
||||
self.runner_instance.setup_databases()
|
||||
mocked_db_creation.return_value.create_test_db.assert_called_once_with(
|
||||
verbosity=0, autoclobber=False, serialize=False, keepdb=False
|
||||
)
|
||||
|
||||
|
||||
@skipUnlessDBFeature("supports_sequence_reset")
|
||||
class AutoIncrementResetTest(TransactionTestCase):
|
||||
|
Loading…
Reference in New Issue
Block a user