File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,12 @@ class ResetSequenceTestCase(django_case):
147147 django_case = ResetSequenceTestCase
148148 else :
149149 from django .test import TestCase as django_case
150+ from django .db import transaction
151+ transaction .Atomic ._ensure_durability = False
152+
153+ def reset_durability ():
154+ transaction .Atomic ._ensure_durability = True
155+ request .addfinalizer (reset_durability )
150156
151157 test_case = django_case (methodName = "__init__" )
152158 test_case ._pre_setup ()
Original file line number Diff line number Diff line change 11import pytest
2- from django .db import connection
2+ from django .db import connection , transaction
33from django .test .testcases import connections_support_transactions
44
5+ from pytest_django .lazy_django import get_django_version
56from pytest_django_test .app .models import Item
67
78
@@ -138,6 +139,12 @@ def test_fin(self, fin):
138139 # Check finalizer has db access (teardown will fail if not)
139140 pass
140141
142+ @pytest .mark .skipif (get_django_version () < (3 , 2 ), reason = "Django >= 3.2 required" )
143+ def test_durable_transactions (self , all_dbs ):
144+ with transaction .atomic (durable = True ):
145+ item = Item .objects .create (name = "foo" )
146+ assert Item .objects .get () == item
147+
141148
142149class TestDatabaseFixturesAllOrder :
143150 @pytest .fixture
You can’t perform that action at this time.
0 commit comments