Ticket #18008: modeltests_fixtures_tests.diff
File modeltests_fixtures_tests.diff, 1.4 KB (added by , 13 years ago) |
---|
-
tests/modeltests/fixtures/tests.py
5 5 from django.contrib.sites.models import Site 6 6 from django.core import management 7 7 from django.db import connection 8 from django.db import IntegrityError 8 9 from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature 9 10 10 11 from .models import Article, Book, Spy, Tag, Visa … … 258 259 # is closed at the end of each test. 259 260 if connection.vendor == 'mysql': 260 261 connection.cursor().execute("SET sql_mode = 'TRADITIONAL'") 261 new_io = StringIO.StringIO() 262 management.call_command('loaddata', 'invalid.json', verbosity=0, stderr=new_io, commit=False) 263 output = new_io.getvalue().strip().split('\n') 264 self.assertRegexpMatches(output[-1], "Error: Could not load fixtures.Article\(pk=1\): .*$") 262 with self.assertRaisesRegexp( 263 IntegrityError, 264 '^Could not load fixtures.Article\(pk=1\): fixtures_article.pub_date may not be NULL$' 265 ): 266 management.call_command('loaddata', 'invalid.json', verbosity=0, commit=False) 265 267 266 268 def test_loading_using(self): 267 269 # Load db fixtures 1 and 2. These will load using the 'default' database identifier explicitly