tags:

views:

257

answers:

3

I work off of the Django trunk and notice that the unit tests for the Django modules in the trunk always have failures. Is the Django trunk supposed to pass all of its own unit tests?

Here are some of the example errors:

======================================================================
ERROR: test_password_change_fails_with_invalid_old_password (django.contrib.auth.tests.views.ChangePasswordTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michael/django/trunk/django/contrib/auth/tests/views.py", line 156, in test_password_change_fails_with_invalid_old_password
    'new_password2': 'password1',
  File "/Users/michael/django/trunk/django/test/client.py", line 318, in post
    response = self.request(**r)
  File "/Users/michael/django/trunk/django/core/handlers/base.py", line 87, in get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/Users/michael/Documents/workspace/drchrono/drchrono_middleware/drchrono.py", line 31, in process_view
    setattr(request, 'currentDoctor', request.user.get_profile().doctor) #Default is to have currentDoctor be default for logged in user.
  File "/Users/michael/django/trunk/django/contrib/auth/models.py", line 285, in get_profile
    self._profile_cache = model._default_manager.get(user__id__exact=self.id)
  File "/Users/michael/django/trunk/django/db/models/manager.py", line 119, in get
    return self.get_query_set().get(*args, **kwargs)
  File "/Users/michael/django/trunk/django/db/models/query.py", line 298, in get
    % self.model._meta.object_name)
DoesNotExist: UserProfile matching query does not exist.

I just realized that a lot of the errors mention a missing UserProfile and that I have a custom UserProfile object that I create when creating a new User through the Web signup process (but that does not get created when instantiating a new User object in the admin or I'll assume through the code.) So maybe this is my app's fault for not creating UserProfiles for users not created through the GUI. How can I create a UserProfile for each User object created? Do you monkeypatch the new() method of the User class?

+3  A: 

The trunk is supposed to pass all of its tests. If you have consistent failures, perhaps your environment is unusual in some way. If different tests fail at different times, you may just be observing typical trunk turmoil.

The django-developers list is pretty responsive about stuff like this. If you ask professionally (for example, not "dudes, your code sux! it doesn't even pass its own tests!!"), they'll help you figure out where the problem is.

Ned Batchelder
I think it may be due to my dev setup. I'm using OSX and MySQL, the majority of the failures seem to be database related of renaming tables and such.
MikeN
Both OSX and MySQL are fully supported, so it's still worth asking about. I'm sure the Django group would prefer that you could run the tests with confidence.
Ned Batchelder
+2  A: 

It was noted in the developers list a few weeks ago (see this thread) that out of the box Django does not pass all its tests. However, this was to do with the lack of particular templates, rather than database tables. Does anything there ring a bell?

Daniel Roseman
This isn't on an out of the box application but a working application.
MikeN