From 6c0539ed7c7a1ddeaac3ff91622ebf7a8c8442b9 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Fri, 6 Jan 2023 09:28:25 +0100 Subject: [PATCH] Refs #32446 -- Removed SERIALIZE test database setting per deprecation timeline. --- django/test/utils.py | 24 +++--------------------- docs/ref/settings.txt | 17 ----------------- docs/releases/1.7.1.txt | 4 ++-- docs/releases/5.0.txt | 2 +- docs/topics/testing/advanced.txt | 4 ---- tests/test_runner/tests.py | 26 +------------------------- 6 files changed, 7 insertions(+), 70 deletions(-) diff --git a/django/test/utils.py b/django/test/utils.py index 5e5649b0ac..cf97ef1526 100644 --- a/django/test/utils.py +++ b/django/test/utils.py @@ -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, diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt index 7c723a824f..4a1891de4e 100644 --- a/docs/ref/settings.txt +++ b/docs/ref/settings.txt @@ -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 `. - -.. deprecated:: 4.0 - - This setting is deprecated as it can be inferred from the - :attr:`~django.test.TestCase.databases` with the - :ref:`serialized_rollback ` option enabled. - .. setting:: TEST_TEMPLATE ``TEMPLATE`` diff --git a/docs/releases/1.7.1.txt b/docs/releases/1.7.1.txt index 6cf0e9edf4..640dfd3a43 100644 --- a/docs/releases/1.7.1.txt +++ b/docs/releases/1.7.1.txt @@ -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 ` entry in the - :setting:`TEST ` dictionary usable (:ticket:`23421`). +* Made the ``SERIALIZE`` entry in the :setting:`TEST ` + dictionary usable (:ticket:`23421`). * Fixed bug in migrations that prevented foreign key constraints to unmanaged models with a custom primary key (:ticket:`23415`). diff --git a/docs/releases/5.0.txt b/docs/releases/5.0.txt index 4b0277d962..f936fc1d77 100644 --- a/docs/releases/5.0.txt +++ b/docs/releases/5.0.txt @@ -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. diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt index fafc4e0bbc..4afb36db3d 100644 --- a/docs/topics/testing/advanced.txt +++ b/docs/topics/testing/advanced.txt @@ -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 `. - If you are using the default test runner, you can control this with the - the :setting:`SERIALIZE ` entry in the :setting:`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``, diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index c4946c3e58..8f39b73e9f 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -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):