From 1d96d886e7f36fcee918b7fa5c32b677bed83b0d Mon Sep 17 00:00:00 2001 From: Paul McMillan Date: Thu, 22 Sep 2011 04:30:20 +0000 Subject: Fixed #16026 -- loaddata now identifies which object triggered an error. git-svn-id: http://code.djangoproject.com/svn/django/trunk@16873 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/fixtures/tests.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/modeltests/fixtures/tests.py b/tests/modeltests/fixtures/tests.py index c335ffbc27..de78d0b4fd 100644 --- a/tests/modeltests/fixtures/tests.py +++ b/tests/modeltests/fixtures/tests.py @@ -252,6 +252,17 @@ class FixtureLoadingTests(TestCase): '' ]) + def test_loaddata_error_message(self): + """ + Verifies that loading a fixture which contains an invalid object + outputs an error message which contains the pk of the object + that triggered the error. + """ + new_io = StringIO.StringIO() + management.call_command('loaddata', 'invalid.json', verbosity=0, stderr=new_io, commit=False) + output = new_io.getvalue().strip().split('\n') + self.assertRegexpMatches(output[-1], "IntegrityError: Could not load fixtures.Article\(pk=1\): .*$") + def test_loading_using(self): # Load db fixtures 1 and 2. These will load using the 'default' database identifier explicitly management.call_command('loaddata', 'db_fixture_1', verbosity=0, using='default', commit=False) -- cgit v1.3