Author: aaugustin
Date: 2011-10-16 07:30:43 -0700 (Sun, 16 Oct 2011)
New Revision: 16996

Modified:
   django/trunk/tests/modeltests/fixtures/tests.py
Log:
Fixed a test that relied on the database to reject invalid data; MySQL doesn't. 
Refs #17055.


Modified: django/trunk/tests/modeltests/fixtures/tests.py
===================================================================
--- django/trunk/tests/modeltests/fixtures/tests.py     2011-10-16 11:04:34 UTC 
(rev 16995)
+++ django/trunk/tests/modeltests/fixtures/tests.py     2011-10-16 14:30:43 UTC 
(rev 16996)
@@ -4,6 +4,7 @@
 
 from django.contrib.sites.models import Site
 from django.core import management
+from django.db import connection
 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
 
 from .models import Article, Book, Spy, Tag, Visa
@@ -260,6 +261,11 @@
         outputs an error message which contains the pk of the object
         that triggered the error.
         """
+        # MySQL needs a little prodding to reject invalid data.
+        # This won't affect other tests because the database connection
+        # is closed at the end of each test.
+        if connection.vendor == 'mysql':
+            connection.cursor().execute("SET sql_mode = 'TRADITIONAL'")
         new_io = StringIO.StringIO()
         management.call_command('loaddata', 'invalid.json', verbosity=0, 
stderr=new_io, commit=False)
         output = new_io.getvalue().strip().split('\n')

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to