Skip to content

Commit 20e965e

Browse files
charettesfelixxm
authored andcommitted
[5.1.x] Refs #35967 -- Doc'd DatabaseCreation.serialize_db_to_string() method.
Backport of 99ac8e2 from main
1 parent 391fde9 commit 20e965e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/topics/testing/advanced.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,18 @@ can be useful during testing.
855855
If the ``keepdb`` argument is ``True``, then the connection to the
856856
database will be closed, but the database will not be destroyed.
857857

858+
.. function:: serialize_db_to_string()
859+
860+
Serializes the database into an in-memory JSON string that can be used to
861+
restore the database state between tests if the backend doesn't support
862+
transactions or if your suite contains test classes with
863+
:ref:`serialized_rollback=True <test-case-serialized-rollback>` enabled.
864+
865+
This function should only be called once all test databases have been
866+
created as the serialization process could result in queries against
867+
non-test databases depending on your
868+
:ref:`routing configuration <topics-db-multi-db-routing>`.
869+
858870
.. _topics-testing-code-coverage:
859871

860872
Integration with ``coverage.py``

0 commit comments

Comments
 (0)