Our team is currently developing our first project with Django, and so
far (~10k lines of Django) it has been pure coding bliss. We recently
hit a snag trying to use the python unit test framework. It seems that
the error that we are seeing occurs even for an essentially empty
Django project (see below). Most likely I am doing something wrong
here, but at the very least the Django code in questions seems counter-
intuitive. This is a first post, so be gentle with the RTFM's if I am
missing something.
Here is what we are trying to do:
Create a minimal Django project, only a single app installed.
Setting.py is unchanged except the db configuration and
installed_apps:
---snip---
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'foobar.polls'
)
---snip---
Now I add a poll app (tutorial style) and write a unit test for the
poll app. The poll app has the normal empty files except an added
tests.py:
---snip---
from django.test import TestCase
class TestDistrictAll(TestCase):
def testDistrictAll(self):
self.assertEquals(1,1)
---snip---
I run syncdb (works fine) and then "manage.py test" and get the error
below. Digging into the python code the problem seems to be that it
wants to remove the contenttype "group" but it is not in the list of
content types. As a result the operation:
content_types.remove(ct)
fails. It is inside a try/except block that catches
ContentType.DoesNotExist exceptions. The operation however triggers a
ValueError which is not caught and causes the test runner to abort.
A quick look at open tickets didn't show anything that seemed
relevant. This is with Python 2.5.1 on a Mac, but we see the same
error on Linux as well. Django is trunk from today as well as a
version that is about two weeks old. We are seeing the same error on a
much larger application as well when we try to run unit tests.
Any help would be most highly appreciated!
Guido
PS: Yes Guido, but no, not that Guido.
--- output of python manage.py test ---
devstation:foobar gappenz$ ./python manage.py test
Creating test database...
Creating table auth_message
Creating table auth_group
Creating table auth_user
Creating table auth_permission
Creating table django_content_type
Creating table django_session
Creating table django_site
Installing index for auth.Message model
Installing index for auth.Permission model
Loading 'initial_data' fixtures...
No fixtures found.
..Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_manager(settings)
File "./django-trunk/django/core/management/__init__.py", line 277,
in execute_manager
utility.execute()
File "./django-trunk/django/core/management/__init__.py", line 225,
in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "./django-trunk/django/core/management/base.py", line 70, in
run_from_argv
self.execute(*args, **options.__dict__)
File "./django-trunk/django/core/management/base.py", line 84, in
execute
output = self.handle(*args, **options)
File "./django-trunk/django/core/management/commands/test.py", line
34, in handle
failures = test_runner(test_labels, verbosity=verbosity,
interactive=interactive)
File "./django-trunk/django/test/simple.py", line 143, in run_tests
result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 705, in run
test(result)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 437, in __call__
return self.run(*args, **kwds)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 433, in run
test(result)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 437, in __call__
return self.run(*args, **kwds)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 433, in run
test(result)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 437, in __call__
return self.run(*args, **kwds)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 433, in run
test(result)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 437, in __call__
return self.run(*args, **kwds)
File "/Users/dev/dps_server/console/support/python-2.5/lib/python2.5/
unittest.py", line 433, in run
test(result)
File "./django-trunk/django/test/testcases.py", line 73, in __call__
self._pre_setup()
File "./django-trunk/django/test/testcases.py", line 59, in
_pre_setup
call_command('flush', verbosity=0, interactive=False)
File "./django-trunk/django/core/management/__init__.py", line 127,
in call_command
return klass.execute(*args, **options)
File "./django-trunk/django/core/management/base.py", line 84, in
execute
output = self.handle(*args, **options)
File "./django-trunk/django/core/management/base.py", line 166, in
handle
return self.handle_noargs(**options)
File "./django-trunk/django/core/management/commands/flush.py", line
64, in handle_noargs
emit_post_sync_signal(models.get_models(), verbosity, interactive)
File "./django-trunk/django/core/management/sql.py", line 457, in
emit_post_sync_signal
verbosity=verbosity, interactive=interactive)
File "./django-trunk/django/dispatch/dispatcher.py", line 360, in
send
**named
File "./django-trunk/django/dispatch/robustapply.py", line 47, in
robustApply
return receiver(*arguments, **named)
File "./django-trunk/django/contrib/contenttypes/management.py",
line 21, in update_contenttypes
content_types.remove(ct)
ValueError: list.remove(x): x not in list
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---