summaryrefslogtreecommitdiff
path: root/tests/many_to_many
diff options
context:
space:
mode:
authorLoic Bistuer <loic.bistuer@gmail.com>2014-03-30 01:57:28 +0700
committerLoic Bistuer <loic.bistuer@gmail.com>2014-03-30 12:13:00 +0700
commitbc9be72bdc9bb4dfc7f967ac3856115f0a6166b8 (patch)
tree04a4a68821d1ba243f4ad7841ebc80da400f591a /tests/many_to_many
parent975337e5c348a770df5a1925ce256ab54cb8c529 (diff)
Fixed transaction handling for a number of operations on related objects.
Thanks Anssi and Aymeric for the reviews. Refs #21174.
Diffstat (limited to 'tests/many_to_many')
-rw-r--r--tests/many_to_many/tests.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/many_to_many/tests.py b/tests/many_to_many/tests.py
index 4293fc0c42..545d50a90e 100644
--- a/tests/many_to_many/tests.py
+++ b/tests/many_to_many/tests.py
@@ -1,5 +1,6 @@
from __future__ import unicode_literals
+from django.db import transaction
from django.test import TestCase
from django.utils import six
@@ -54,7 +55,9 @@ class ManyToManyTests(TestCase):
# Adding an object of the wrong type raises TypeError
with six.assertRaisesRegex(self, TypeError, "'Publication' instance expected, got <Article.*"):
- a6.publications.add(a5)
+ with transaction.atomic():
+ a6.publications.add(a5)
+
# Add a Publication directly via publications.add by using keyword arguments.
a6.publications.create(title='Highlights for Adults')
self.assertQuerysetEqual(a6.publications.all(),