mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #35660 -- Made serialized_rollback and fixture data available in TransactionTestCase.setUpClass().
This commit is contained in:
parent
8eca3e9bce
commit
a060a22ee2
8 changed files with 91 additions and 16 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue