summaryrefslogtreecommitdiff
path: root/docs/topics/testing/tools.txt
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2024-09-04 09:33:44 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-09-17 09:53:46 +0200
commita060a22ee2dde7aa29a5a29120087c4864887325 (patch)
tree929416b98a47878d8707f634f4863c84b03f8f9e /docs/topics/testing/tools.txt
parent8eca3e9bce519c21340312ee7846c92b27abea79 (diff)
Fixed #35660 -- Made serialized_rollback and fixture data available in TransactionTestCase.setUpClass().
Diffstat (limited to 'docs/topics/testing/tools.txt')
-rw-r--r--docs/topics/testing/tools.txt34
1 files changed, 22 insertions, 12 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index 363505a0fc..7830f5e575 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -1262,25 +1262,35 @@ subclass::
Here's specifically what will happen:
-* At the start of each test, before ``setUp()`` is run, Django will flush the
- database, returning the database to the state it was in directly after
- :djadmin:`migrate` was called.
+* During ``setUpClass()``, all the named fixtures are installed. In this
+ example, Django will install any JSON fixture named ``mammals``, followed by
+ any fixture named ``birds``. See the :ref:`fixtures-explanation` topic for
+ more details on defining and installing fixtures.
-* Then, all the named fixtures are installed. In this example, Django will
- install any JSON fixture named ``mammals``, followed by any fixture named
- ``birds``. See the :ref:`fixtures-explanation` topic for more details on
- defining and installing fixtures.
+For most unit tests using :class:`TestCase`, Django doesn't need to do
+anything else, because transactions are used to clean the database after each
+test for performance reasons. But for :class:`TransactionTestCase`, the
+following actions will take place:
-For performance reasons, :class:`TestCase` loads fixtures once for the entire
-test class, before :meth:`~TestCase.setUpTestData`, instead of before each
-test, and it uses transactions to clean the database before each test. In any case,
-you can be certain that the outcome of a test will not be affected by another
-test or by the order of test execution.
+* At the end of each test Django will flush the database, returning the
+ database to the state it was in directly after :djadmin:`migrate` was
+ called.
+
+* For each subsequent test, the fixtures will be reloaded before ``setUp()``
+ is run.
+
+In any case, you can be certain that the outcome of a test will not be
+affected by another test or by the order of test execution.
By default, fixtures are only loaded into the ``default`` database. If you are
using multiple databases and set :attr:`TransactionTestCase.databases`,
fixtures will be loaded into all specified databases.
+.. versionchanged:: 5.2
+
+ For :class:`TransactionTestCase`, fixtures were made available during
+ ``setUpClass()``.
+
URLconf configuration
---------------------