The requirements of having `TransactionTestCase` subclasses declare
databases they are allowed to interact with that was introduced by #28478
paired with the requirement to opt-in the serialization behaviour through
`serialized_rollback=False` allows the suite to determine if data state
serialization for each test database is necessary at discovery time which
makes the setting unnecessary.
I therefore suggest we deprecate the `SERIALIZE` test database and base
per-database serialization on the subset of discovered
`TransactionTestCase.databases` declared with `serialized_rollback =
True`. This should change the default to avoiding unnecessary state
serialization of test databases which can add up pretty quickly in large
Django projects with a lot of apps and models (one unnecessary query for
each model present).
--
Ticket URL: <https://code.djangoproject.com/ticket/32446>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> The [https://docs.djangoproject.com/en/3.1/ref/settings/#serialize
> SERIALIZE] test database setting controls whether or not the content of
> test databases state should be serialized and restored between tests
> which enables the `TransactionTestCase.serialized_rollback`
> [https://docs.djangoproject.com/en/3.1/topics/testing/overview/#test-
> case-serialized-rollback feature] feature. It defaults to `True` and the
> documentation encourage turning it off to speed up test database creation
> time.
>
> The requirements of having `TransactionTestCase` subclasses declare
> databases they are allowed to interact with that was introduced by #28478
> paired with the requirement to opt-in the serialization behaviour through
> `serialized_rollback=False` allows the suite to determine if data state
> serialization for each test database is necessary at discovery time which
> makes the setting unnecessary.
>
> I therefore suggest we deprecate the `SERIALIZE` test database and base
> per-database serialization on the subset of discovered
> `TransactionTestCase.databases` declared with `serialized_rollback =
> True`. This should change the default to avoiding unnecessary state
> serialization of test databases which can add up pretty quickly in large
> Django projects with a lot of apps and models (one unnecessary query for
> each model present).
New description:
The [https://docs.djangoproject.com/en/3.1/ref/settings/#serialize
SERIALIZE] test database setting controls whether or not the content of
test databases state should be serialized and restored between tests which
enables the `TransactionTestCase.serialized_rollback`
[https://docs.djangoproject.com/en/3.1/topics/testing/overview/#test-case-
serialized-rollback feature]. It defaults to `True` and the documentation
encourage turning it off to speed up test database creation time.
The requirements of having `TransactionTestCase` subclasses declare
databases they are allowed to interact with that was introduced by #28478
paired with the requirement to opt-in the serialization behaviour through
`serialized_rollback=False` allows the suite to determine if data state
serialization for each test database is necessary at discovery time which
makes the setting unnecessary.
I therefore suggest we deprecate the `SERIALIZE` test database and base
per-database serialization on the subset of discovered
`TransactionTestCase.databases` declared with `serialized_rollback =
True`. This should change the default to avoiding unnecessary state
serialization of test databases which can add up pretty quickly in large
Django projects with a lot of apps and models (one unnecessary query for
each model present).
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:1>
* owner: nobody => Simon Charette
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:2>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
Comment:
[https://github.com/django/django/pull/14010 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:3>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:4>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"3089018e951dcca568574c0e0ebf9d8aab112389" 3089018e]:
{{{
#!CommitTicketReference repository=""
revision="3089018e951dcca568574c0e0ebf9d8aab112389"
Fixed #32446 -- Deprecated SERIALIZE test database setting.
Whether or not the state of a test database should be serialized can be
inferred from the set of databases allowed to be access from discovered
TestCase/TransactionTestCase enabling the serialized_rollback feature
which makes this setting unnecessary.
This should make a significant test suite bootstraping time difference
on large projects that didn't explicitly disable test database
serialization.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:6>
Comment (by Adam Johnson):
Great work! I will be able to delete a section in my book now.
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:7>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"6c0539ed7c7a1ddeaac3ff91622ebf7a8c8442b9" 6c0539ed]:
{{{
#!CommitTicketReference repository=""
revision="6c0539ed7c7a1ddeaac3ff91622ebf7a8c8442b9"
Refs #32446 -- Removed SERIALIZE test database setting per deprecation
timeline.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32446#comment:8>