Opened 17 years ago
Closed 17 years ago
#4328 closed (duplicate)
client.get() always fails on django.contrib.auth.views.logout
Reported by: | anonymous | Owned by: | Adrian Holovaty |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Keywords: | client | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I use built-in auth logout view, when I use browser to access /accounts/logout there is no problems at all, it works just great. But when I try to develop test case using django.test.Client, it always fails to get this URL. It is funny, why exactly this URL. I have tests all built-in auth views (login, password_reset, password_change, etc.) all do work, but this logout. I have updated to the latest SVN, but it doesn't help.
urls.py:
from django.conf.urls.defaults import *
import django.contrib.auth.views
urlpatterns = patterns(,
(r'accounts/login/$', django.contrib.auth.views.login),
(r'accounts/logout/$', django.contrib.auth.views.logout),
)
This line always fails:
client.get('/accounts/logout/', {'la-la':'la-la'})
Traceback (most recent call last):
File "/usr/home/and/workspace/economics/src/../src/registration/tests.py", line 32, in test_get_view
response = self.client.get('/accounts/logout/', {'lang' : 'en'})
File "/usr/local/lib/python2.5/site-packages/django/test/client.py", line 203, in get
return self.request(r)
File "/usr/local/lib/python2.5/site-packages/django/test/client.py", line 168, in request
response = self.handler(environ)
File "/usr/local/lib/python2.5/site-packages/django/test/client.py", line 38, in call
response = self.get_response(request)
File "/usr/local/lib/python2.5/site-packages/django/core/handlers/base.py", line 126, in get_response
return callback(request, param_dict)
File "/usr/local/lib/python2.5/site-packages/django/views/defaults.py", line 88, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "/usr/local/lib/python2.5/site-packages/django/template/loader.py", line 79, in get_template
source, origin = find_template_source(template_name)
File "/usr/local/lib/python2.5/site-packages/django/template/loader.py", line 72, in find_template_source
raise TemplateDoesNotExist, name
TemplateDoesNotExist: 500.html
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
I have spotted the bug. FINALLY.
client.get('/accounts/logout/', {'lang' : 'en'}) fails because the function _(), which meant to be shortcut for
gettext, is not seen. Three is some bool variable '_' instead. This happens only if test environment is launched (manage.py test)
Since only logout_view from django.contrib.auth.views uses i18n, that is why it fails to get it.
comment:3 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
This is the problem described in #2920. We're going to end up not installing _() in builtins because of these exact problems. Closing this as a dupe for that reason.
I can't get it, why it is like that.
I decided to add an empty 500.html template and this what I get afterwards. I did do nothing, except adding this empty 500.html. PROMISE!
line: client.get('/accounts/logout/', {'lang' : 'en'})
Traceback (most recent call last):
TypeError: 'bool' object is not callable
Ran 3 tests in 4.253s
FAILED (errors=1)
Where does this bool object appeared from. I have reviewed django.contrib.auth.views 20 times, still I can't
understand what is wrong.