summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2008-11-06 11:27:33 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2008-11-06 11:27:33 +0000
commit6be20bf64c63180103ae92bfa6e068b8c8102b7a (patch)
treebe3ac83b5914fa08dfe18faf80ae235a8a53b61d /tests
parent697f73f4889f9fd2739acd470b11e364cc14a3c4 (diff)
[1.0.X] Fixed #9011 -- Corrected handling of fixture files that contain errors to correctly report the broken fixture name. Thanks to jlrivitti@gmail.com for the report and initial patch.
Merge of [9357] and [9358] from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9359 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/fixtures_regress/fixtures/empty.json1
-rw-r--r--tests/regressiontests/fixtures_regress/models.py15
2 files changed, 13 insertions, 3 deletions
diff --git a/tests/regressiontests/fixtures_regress/fixtures/empty.json b/tests/regressiontests/fixtures_regress/fixtures/empty.json
new file mode 100644
index 0000000000..0637a088a0
--- /dev/null
+++ b/tests/regressiontests/fixtures_regress/fixtures/empty.json
@@ -0,0 +1 @@
+[] \ No newline at end of file
diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py
index 9bca78bc59..373980bb66 100644
--- a/tests/regressiontests/fixtures_regress/models.py
+++ b/tests/regressiontests/fixtures_regress/models.py
@@ -7,7 +7,7 @@ class Animal(models.Model):
name = models.CharField(max_length=150)
latin_name = models.CharField(max_length=150)
count = models.IntegerField()
-
+
def __unicode__(self):
return self.common_name
@@ -56,7 +56,7 @@ class Channel(models.Model):
class Article(models.Model):
title = models.CharField(max_length=255)
channels = models.ManyToManyField(Channel)
-
+
class Meta:
ordering = ('id',)
@@ -113,6 +113,15 @@ No fixture data found for 'bad_fixture2'. (File format may be invalid.)
>>> management.call_command('loaddata', 'bad_fixture2', verbosity=0)
No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+# Loading a fixture file with no data returns an error
+>>> management.call_command('loaddata', 'empty', verbosity=0)
+No fixture data found for 'empty'. (File format may be invalid.)
+
+# If any of the fixtures contain an error, loading is aborted
+# (Regression for #9011 - error message is correct)
+>>> management.call_command('loaddata', 'bad_fixture2', 'animal', verbosity=0)
+No fixture data found for 'bad_fixture2'. (File format may be invalid.)
+
>>> sys.stderr = savestderr
###############################################
@@ -123,7 +132,7 @@ No fixture data found for 'bad_fixture2'. (File format may be invalid.)
>>> management.call_command('loaddata', 'model-inheritance.json', verbosity=0)
###############################################
-# Test for ticket #7572 -- MySQL has a problem if the same connection is
+# Test for ticket #7572 -- MySQL has a problem if the same connection is
# used to create tables, load data, and then query over that data.
# To compensate, we close the connection after running loaddata.
# This ensures that a new connection is opened when test queries are issued.