Opened 18 years ago

Closed 17 years ago

#2734 closed defect (duplicate)

Test framework doesn't install _(), maybe?

Reported by: dave AT avaragado.org Owned by: Adrian Holovaty
Component: Testing framework Version: dev
Severity: normal Keywords:
Cc: mir@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 Adrian Holovaty, 18 years ago

Summary: django.contrib.auth.views.logout uses _ without importingTest framework doesn't install _(), maybe?

The _ function isn't meant to be imported, as django.utils.translation.trans_real.install automatically puts it in the global namespace. I suspect this is a problem with the testing framework, then...

comment:2 by mir@…, 18 years ago

Cc: mir@… 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 Michael Radziej <mir@…>, 17 years ago

Component: Contrib appsUnit test system
Resolution: duplicate
Status: newclosed

duplicate of #2920

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