summaryrefslogtreecommitdiff
path: root/tests/modeltests/serializers/tests.py
diff options
context:
space:
mode:
authorKaren Tracey <kmtracey@gmail.com>2011-08-07 00:43:26 +0000
committerKaren Tracey <kmtracey@gmail.com>2011-08-07 00:43:26 +0000
commitbe87f0b0ec992e6f3e72735d8e95c654da969f6d (patch)
treefa4d16b640e716dcd8271f2e6a7e3bb2953cbe5d /tests/modeltests/serializers/tests.py
parente3c89346d217fca92b62a6d11df6b4b6d5be28a2 (diff)
downloaddjango-be87f0b0ec992e6f3e72735d8e95c654da969f6d.tar.gz
Fixed #3615: Added support for loading fixtures with forward references on database backends (such as MySQL/InnoDB) that do not support deferred constraint checking. Many thanks to jsdalton for coming up with a clever solution to this long-standing issue, and to jacob, ramiro, graham_king, and russellm for review/testing. (Apologies if I missed anyone else who helped here.)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16590 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/serializers/tests.py')
-rw-r--r--tests/modeltests/serializers/tests.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py
index 4a7e0a2086..def0254a9f 100644
--- a/tests/modeltests/serializers/tests.py
+++ b/tests/modeltests/serializers/tests.py
@@ -1,3 +1,7 @@
+# This is necessary in Python 2.5 to enable the with statement, in 2.6
+# and up it is no longer necessary.
+from __future__ import with_statement
+
# -*- coding: utf-8 -*-
from datetime import datetime
from StringIO import StringIO
@@ -5,7 +9,7 @@ from xml.dom import minidom
from django.conf import settings
from django.core import serializers
-from django.db import transaction
+from django.db import transaction, connection
from django.test import TestCase, TransactionTestCase, Approximate
from django.utils import simplejson, unittest
@@ -252,8 +256,9 @@ class SerializersTransactionTestBase(object):
transaction.enter_transaction_management()
transaction.managed(True)
objs = serializers.deserialize(self.serializer_name, self.fwd_ref_str)
- for obj in objs:
- obj.save()
+ with connection.constraint_checks_disabled():
+ for obj in objs:
+ obj.save()
transaction.commit()
transaction.leave_transaction_management()