Skip to content

Commit b015ae9

Browse files
committed
Inline @transaction.non_atomic_requests for Django<1.6.
1 parent c292b3d commit b015ae9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/test_atomic_requests.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,6 @@ def post(self, request, *args, **kwargs):
3333
raise APIException
3434

3535

36-
class NonAtomicAPIExceptionView(APIView):
37-
@method_decorator(transaction.non_atomic_requests)
38-
def dispatch(self, *args, **kwargs):
39-
return super(NonAtomicAPIExceptionView, self).dispatch(*args, **kwargs)
40-
41-
def post(self, request, *args, **kwargs):
42-
BasicModel.objects.create()
43-
raise PermissionDenied
44-
45-
4636
@skipUnless(connection.features.uses_savepoints,
4737
"'atomic' requires transactions and savepoints.")
4838
class DBTransactionTests(TestCase):
@@ -125,6 +115,16 @@ def test_api_exception_rollback_transaction(self):
125115
"'atomic' requires transactions and savepoints.")
126116
class NonAtomicDBTransactionAPIExceptionTests(TestCase):
127117
def setUp(self):
118+
# only Django >= 1.6 provides @transaction.non_atomic_requests
119+
class NonAtomicAPIExceptionView(APIView):
120+
@method_decorator(transaction.non_atomic_requests)
121+
def dispatch(self, *args, **kwargs):
122+
return super(NonAtomicAPIExceptionView, self).dispatch(*args, **kwargs)
123+
124+
def post(self, request, *args, **kwargs):
125+
BasicModel.objects.create()
126+
raise PermissionDenied
127+
128128
self.view = NonAtomicAPIExceptionView.as_view()
129129
connections.databases['default']['ATOMIC_REQUESTS'] = True
130130

0 commit comments

Comments
 (0)