1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed #35660 -- Made serialized_rollback and fixture data available in TransactionTestCase.setUpClass().

This commit is contained in:
Jacob Walls
2024-09-04 09:33:44 -04:00
committed by Sarah Boyce
parent 8eca3e9bce
commit a060a22ee2
8 changed files with 91 additions and 16 deletions

View File

@@ -4,7 +4,7 @@ from django.db import connections
from django.test import TestCase, TransactionTestCase, override_settings
from django.test.testcases import DatabaseOperationForbidden
from .models import Car
from .models import Car, Person
class TestSerializedRollbackInhibitsPostMigrate(TransactionTestCase):
@@ -68,3 +68,16 @@ class DisallowedDatabaseQueriesTests(TransactionTestCase):
)
with self.assertRaisesMessage(DatabaseOperationForbidden, message):
Car.objects.using("other").get()
class FixtureAvailableInSetUpClassTest(TransactionTestCase):
available_apps = ["test_utils"]
fixtures = ["person.json"]
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.elvis = Person.objects.get(name="Elvis Presley")
def test_fixture_loaded_during_class_setup(self):
self.assertIsInstance(self.elvis, Person)