Opened 15 years ago

Closed 15 years ago

#10746 closed (duplicate)

django.contrib.auth logout test fails after [10332]

Reported by: Matthew Flanagan <mattimustang@…> Owned by: nobody
Component: contrib.auth Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The test_logout_default fails for me when I run my projects test suite. I have django.contrib.auth in my INSTALLED_APPS. The traceback is (note this is a red-herring):

======================================================================
ERROR: Logout without next_page option renders the default template
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/xxx/django/django/contrib/auth/tests/views.py", line 208, in test_logout_default
    response = self.client.get('/logout_test/')
  File "/xxx/django/django/test/client.py", line 280, in get
    response = self.request(**r)
  File "/xxx/vendor/django/django/test/client.py", line 224, in request
    response = self.handler(environ)
  File "/xxx/vendor/django/django/test/client.py", line 68, in __call__
    response = self.get_response(request)
  File "/xxx/vendor/django/django/core/handlers/base.py", line 122, in get_response
    return self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/xxx/nong/vendor/django/django/core/handlers/base.py", line 165, in handle_uncaught_exception
    callback, param_dict = resolver.resolve500()
  File "/xxx/vendor/django/django/core/urlresolvers.py", line 229, in resolve500
    return self._resolve_special('500')
  File "/xxx/vendor/django/django/core/urlresolvers.py", line 218, in _resolve_special
    callback = getattr(self.urlconf_module, 'handler%s' % view_type)
AttributeError: 'module' object has no attribute 'handler500'

----------------------------------------------------------------------

Which template the logout view uses depends on your INSTALLED_APPS list order and whether or not you have your own registration/logged_out.html, which I do.

The traceback above is a red-herring because what is happening is that the logout view is finding my project's registration/logged_out.html template which has a few {% url ... %}'s in it but the test runner is unable to resolve all those other urls thus causing a 500 error.

After investigating I discovered two things:

  1. django.contrib.auth.urls has a ^logout/$ url regex and django.contrib.auth.tests.urls imports urlpatterns from django.contrib.auth.urls and appends to it a list of test URLs including an identical ^logout/$ regex. If you renamed the latter to ^logout_test/$ and update 2 tests to use it then you will be assured that you are testing what you intended.
  1. The test suite's ^logout_test/$ url should also define which template_name it uses so it won't try to load any old registration/logged_out.html and fail.

The patch attached fixes this.

Change History (1)

comment:1 by Russell Keith-Magee, 15 years ago

Resolution: duplicate
Status: newclosed

Dupe of #10747

Note: See TracTickets for help on using tickets.
Back to Top