Opened 19 years ago
Closed 18 years ago
#2734 closed defect (duplicate)
Test framework doesn't install _(), maybe?
Description ¶
The call to render_to_response includes the i18n magic _ function, but it hasn't been imported. Result: grief, in conjunction with the new test client at least (it gives me a 500 response).
To fix: import _ from the usual place. I trust a patch submission for this change is not required :-)
Change History (3)
comment:1 by , 19 years ago
Summary: | django.contrib.auth.views.logout uses _ without importing → Test framework doesn't install _(), maybe? |
---|
comment:2 by , 19 years ago
Cc: | added |
---|
I had exactly this problem with my own test stuff, and the problem turned out to be a little bit nasty. I use py.test together with doctests. During doctests, _ will be overwritten with each evaluated value, as happens during interactive use.
I solved it by doing
__builtins__['_'] = gettext
after each doctest. You can't use the '_' of i18n in doctests, but this never a problem for me.
Perhaps this can be done in the new django test framework, too.
comment:3 by , 18 years ago
Component: | Contrib apps → Unit test system |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
duplicate of #2920
The
_
function isn't meant to be imported, asdjango.utils.translation.trans_real.install
automatically puts it in the global namespace. I suspect this is a problem with the testing framework, then...