Ticket #18008: modeltests_fixtures_tests.diff

File modeltests_fixtures_tests.diff, 1.4 KB (added by hoffmaje, 12 years ago)
  • tests/modeltests/fixtures/tests.py

     
    55from django.contrib.sites.models import Site
    66from django.core import management
    77from django.db import connection
     8from django.db import IntegrityError
    89from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
    910
    1011from .models import Article, Book, Spy, Tag, Visa
     
    258259        # is closed at the end of each test.
    259260        if connection.vendor == 'mysql':
    260261            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)
    265267
    266268    def test_loading_using(self):
    267269        # Load db fixtures 1 and 2. These will load using the 'default' database identifier explicitly
Back to Top