I'm trying to run the Django unit tests for the first time using 
runtests.py and I'm getting a lot of errors like this:


 > Problem installing fixture 
'/develop/django/tests/regressiontests/views/fixtures/testdata.json': 
Traceback (most recent call last):
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/commands/loaddata.py",
 
line 112, in handle
 >     obj.save()
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/serializers/base.py",
 
line 168, in save
 >     models.Model.save_base(self.object, raw=True)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/base.py",
 
line 334, in save_base
 >     result = manager._insert(values, return_id=update_pk)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/manager.py",
 
line 127, in _insert
 >     return insert_query(self.model, values, **kwargs)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py",
 
line 735, in insert_query
 >     return query.execute_sql(return_id)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/subqueries.py",
 
line 300, in execute_sql
 >     cursor = super(InsertQuery, self).execute_sql(None)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/sql/query.py",
 
line 1474, in execute_sql
 >     cursor.execute(sql, params)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/MySQLdb/cursors.py",
 
line 166, in execute
 >     self.errorhandler(self, exc, value)
 >   File 
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/MySQLdb/connections.py",
 
line 35, in defaulterrorhandler
 >     raise errorclass, errorvalue
 > IntegrityError: (1452, 'Cannot add or update a child row: a foreign 
key constraint fails (`test_django_regression/views_article`, CONSTRAINT 
`author_id_refs_id_559385ef` FOREIGN KEY (`author_id`) REFERENCES 
`views_author` (`id`))')


As far as I can see, the errors are legitimate because 
regressiontests/views/fixtures/testdata.json defines several 
views.article items before it defines the views.author item that they 
refer to. If I move

 >     {
 >         "pk": 1,         "model": "views.author",         "fields": {
 >             "name": "Boris"
 >         }
 >     },

to the top of the testdata.json, instead of near the bottom where it 
currently is, the errors disappear. However, testdata.json has been 
defined this way from the time it was created, leading me to wonder why 
others haven't been having the same problem.

Note that the errors I mention above don't actually occur as unit test 
failures (though they do cause other failures to occur): instead, they 
appear in the progress information while the unit tests are running.


Mike


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to