summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul McMillan <Paul@McMillan.ws>2011-09-22 04:30:20 +0000
committerPaul McMillan <Paul@McMillan.ws>2011-09-22 04:30:20 +0000
commit1d96d886e7f36fcee918b7fa5c32b677bed83b0d (patch)
tree9a5ce5c9b6c2f05c3261f08451d439c292285b34 /tests
parent0781ed8ec8dab4f4658787c9dc1ca8499ccc1a18 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/modeltests/fixtures/tests.py11
1 files changed, 11 insertions, 0 deletions
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):
'<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)