1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

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
This commit is contained in:
Paul McMillan
2011-09-22 04:30:20 +00:00
parent 0781ed8ec8
commit 1d96d886e7
2 changed files with 23 additions and 2 deletions

View File

@@ -252,6 +252,17 @@ class FixtureLoadingTests(TestCase):
'<Article: Python program becomes self aware>'
])
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)