summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2025-02-16 08:36:12 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2025-02-16 13:46:34 +0100
commit20e965e869d657a3a24ddac6065ee494f283aa18 (patch)
tree0d76080f84987cdc6231bcc95e9a79f445dc708d
parent391fde9e54b346f08aed4d9af6e72affc34ac38a (diff)
[5.1.x] Refs #35967 -- Doc'd DatabaseCreation.serialize_db_to_string() method.
Backport of 99ac8e2589ea978c1c80ff66b4536814121f77dd from main
-rw-r--r--docs/topics/testing/advanced.txt12
1 files changed, 12 insertions, 0 deletions
diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt
index d889bd02ee..ab32e28efc 100644
--- a/docs/topics/testing/advanced.txt
+++ b/docs/topics/testing/advanced.txt
@@ -855,6 +855,18 @@ can be useful during testing.
If the ``keepdb`` argument is ``True``, then the connection to the
database will be closed, but the database will not be destroyed.
+.. function:: serialize_db_to_string()
+
+ Serializes the database into an in-memory JSON string that can be used to
+ restore the database state between tests if the backend doesn't support
+ transactions or if your suite contains test classes with
+ :ref:`serialized_rollback=True <test-case-serialized-rollback>` enabled.
+
+ This function should only be called once all test databases have been
+ created as the serialization process could result in queries against
+ non-test databases depending on your
+ :ref:`routing configuration <topics-db-multi-db-routing>`.
+
.. _topics-testing-code-coverage:
Integration with ``coverage.py``