summaryrefslogtreecommitdiff
path: root/tests/test_utils
diff options
context:
space:
mode:
authorJacob Walls <jacobtylerwalls@gmail.com>2024-09-04 09:33:44 -0400
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-09-17 09:53:46 +0200
commita060a22ee2dde7aa29a5a29120087c4864887325 (patch)
tree929416b98a47878d8707f634f4863c84b03f8f9e /tests/test_utils
parent8eca3e9bce519c21340312ee7846c92b27abea79 (diff)
Fixed #35660 -- Made serialized_rollback and fixture data available in TransactionTestCase.setUpClass().
Diffstat (limited to 'tests/test_utils')
-rw-r--r--tests/test_utils/fixtures/person.json (renamed from tests/test_utils/fixtures/should_not_be_loaded.json)0
-rw-r--r--tests/test_utils/test_transactiontestcase.py15
-rw-r--r--tests/test_utils/tests.py2
3 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_utils/fixtures/should_not_be_loaded.json b/tests/test_utils/fixtures/person.json
index 9f4df38996..9f4df38996 100644
--- a/tests/test_utils/fixtures/should_not_be_loaded.json
+++ b/tests/test_utils/fixtures/person.json
diff --git a/tests/test_utils/test_transactiontestcase.py b/tests/test_utils/test_transactiontestcase.py
index 0032e2ee0c..12ef4c9a1c 100644
--- a/tests/test_utils/test_transactiontestcase.py
+++ b/tests/test_utils/test_transactiontestcase.py
@@ -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)
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 1110466fcf..4fd9267429 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -1214,7 +1214,7 @@ class XMLEqualTests(SimpleTestCase):
class SkippingExtraTests(TestCase):
- fixtures = ["should_not_be_loaded.json"]
+ fixtures = ["person.json"]
# HACK: This depends on internals of our TestCase subclasses
def __call__(self, result=None):