diff options
| author | Jacob Walls <jacobtylerwalls@gmail.com> | 2024-09-04 09:33:44 -0400 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-09-17 09:53:46 +0200 |
| commit | a060a22ee2dde7aa29a5a29120087c4864887325 (patch) | |
| tree | 929416b98a47878d8707f634f4863c84b03f8f9e /tests/migration_test_data_persistence | |
| parent | 8eca3e9bce519c21340312ee7846c92b27abea79 (diff) | |
Fixed #35660 -- Made serialized_rollback and fixture data available in TransactionTestCase.setUpClass().
Diffstat (limited to 'tests/migration_test_data_persistence')
| -rw-r--r-- | tests/migration_test_data_persistence/tests.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/migration_test_data_persistence/tests.py b/tests/migration_test_data_persistence/tests.py index 862a06c4a5..a04259bba1 100644 --- a/tests/migration_test_data_persistence/tests.py +++ b/tests/migration_test_data_persistence/tests.py @@ -1,3 +1,4 @@ +from django.core.management import call_command from django.test import TestCase, TransactionTestCase from .models import Book @@ -19,6 +20,26 @@ class MigrationDataPersistenceTestCase(TransactionTestCase): ) +class MigrationDataPersistenceClassSetup(TransactionTestCase): + """ + Data loaded in migrations is available during class setup if + TransactionTestCase.serialized_rollback = True. + """ + + available_apps = ["migration_test_data_persistence"] + serialized_rollback = True + + @classmethod + def setUpClass(cls): + # Simulate another TransactionTestCase having just torn down. + call_command("flush", verbosity=0, interactive=False) + super().setUpClass() + cls.book = Book.objects.first() + + def test_data_available_in_class_setup(self): + self.assertIsInstance(self.book, Book) + + class MigrationDataNormalPersistenceTestCase(TestCase): """ Data loaded in migrations is available on TestCase |
