From c55a808198e797598956a000a240dc74d84c7d3d Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 16 Feb 2025 08:36:12 +0100 Subject: [PATCH] [5.2.x] Refs #35967 -- Doc'd DatabaseCreation.serialize_db_to_string() method. Backport of 99ac8e2589ea978c1c80ff66b4536814121f77dd from main --- docs/topics/testing/advanced.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt index 6b03f0f82b..915d8c971e 100644 --- a/docs/topics/testing/advanced.txt +++ b/docs/topics/testing/advanced.txt @@ -851,6 +851,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 ` 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-testing-code-coverage: Integration with ``coverage.py``