Opened 13 years ago

Closed 13 years ago

#15280 closed (wontfix)

Django validation error messages are always shown in English when running unit tests

Reported by: Denilson Figueiredo de Sá Owned by: nobody
Component: Uncategorized Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

How to reproduce:

  • Start a new project and set LANGUAGE_CODE to something other than 'en-us'. For instance, let's put 'pt-br'.
  • Create a view that renders a bounded form.
  • Pass invalid data to that form, so that the form will output some (django built-in) validation error messages.
  • Look at the error message at the browser. Notice it is in Portuguese (or whatever language you have set).
  • Now write a unit test that checks if your view actually shows that error message.
  • BOO! The test fails! When running unit tests, the django error messages are shown in English, ignoring the LANGUAGE_CODE setting.

I'm attaching a tarball with a minimalistic project showing this bug.

In my opinion, django should behave the same whenever running as server or running the unit tests. Thus, I believe this behavior is a bug.

Tested against Django 1.2.4

Attachments (1)

django_language_during_tests.tar.gz (3.5 KB ) - added by Denilson Figueiredo de Sá 13 years ago.

Download all attachments as: .zip

Change History (2)

by Denilson Figueiredo de Sá, 13 years ago

comment:1 by Karen Tracey, 13 years ago

Resolution: wontfix
Status: newclosed

What about re-usable apps that ship with tests that include testing error strings as you are talking about? They would all suddenly start failing on projects with non-en-us locales set, because they were written to test against default en-us string values.

If you want to test a specific language error string, then you need to activate that locale in your test. How to do that is noted on this page: http://docs.djangoproject.com/en/1.2/howto/custom-management-commands/.

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