开发者

What to do if Django's trunks own unit tests fail?

开发者 https://www.devze.com 2022-12-09 12:32 出处:网络
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?

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)
  F开发者_C百科ile "/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?


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.


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?


I'm using django 1.2.3(a stable release, not the trunk). When I create an empty application and run ./manage.py test, I get three tests failing, one of which is the one indicated above. In my case however, the error is related to a missing template: TemplateDoesNotExist: registration/password_change_form.html. That's why I think(like Daniel) it's really a problem with missing templates.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号