Ticket #18011: tests_regressiontests_fixtures_regress_tests.diff
File tests_regressiontests_fixtures_regress_tests.diff, 1.7 KB (added by , 13 years ago) |
---|
-
tests/regressiontests/fixtures_regress/tests.py
12 12 from django.core import management 13 13 from django.core.management.base import CommandError 14 14 from django.core.management.commands.dumpdata import sort_dependencies 15 from django.db import IntegrityError 15 16 from django.db import transaction 16 17 from django.db.models import signals 17 18 from django.test import (TestCase, TransactionTestCase, skipIfDBFeature, … … 375 376 self.assertEqual(Book.objects.all()[0].id, 1) 376 377 self.assertEqual(Person.objects.all()[0].id, 4) 377 378 378 def test_loaddata_raises_ error_when_fixture_has_invalid_foreign_key(self):379 def test_loaddata_raises_IntegrityError_when_fixture_has_invalid_foreign_key(self): 379 380 """ 380 381 Regression for #3615 - Ensure data with nonexistent child key references raises error 381 382 """ 382 stderr = StringIO() 383 management.call_command( 384 'loaddata', 385 'forward_ref_bad_data.json', 386 verbosity=0, 387 commit=False, 388 stderr=stderr, 389 ) 390 self.assertTrue( 391 stderr.getvalue().startswith('Problem installing fixture') 392 ) 383 with self.assertRaisesRegexp(IntegrityError, '[.]*has an invalid foreign key[.]*'): 384 management.call_command( 385 'loaddata', 386 'forward_ref_bad_data.json', 387 verbosity=0, 388 commit=False, 389 ) 393 390 394 391 _cur_dir = os.path.dirname(os.path.abspath(__file__)) 395 392