Weird test-behaviour in combination with localization

20 views
Skip to first unread message

Andre Schemschat

unread,
Jul 31, 2012, 3:21:28 PM7/31/12
to django...@googlegroups.com
Hey together,
I was just writing some tests for my views and i stumbled upon a localization error, which i cant figure out :/
I have a test that checks the form-validation returnes the correct errors-messages for specific input data. Basicly what i feed to the view are the field-names and their values and in return i get a json-string with the error-messages for the fields.
This works fine, if i just run the tests for that specific view. (Result is something like {'fielda':'Dieses Feld ist zwingend erforderlich.'}, where 'Dieses Feld ist zwingend erforderlich.'=>'This field is required' in german). 
Now, if i run all tests, not just for that specific view, the test fails, because the view returnes {'fielda':'This field is required.'} instead of the german localization. I checked the settings.LANGUAGE_CODE-value in the view and in the test, in both cases it is de-de.
Any ideas, why my test is fine if it runs alone and fails when all tests of the project (including the django-ones) are run? Im fresh out of ideas and a little bit puzzled :D

Greetings & Thanks,
Andre

Andre Schemschat

unread,
Jul 31, 2012, 6:35:27 PM7/31/12
to django...@googlegroups.com
Ok, so I fixed my problem, but i have the feelings this cant really be a longterm solution ^^. If i create my own testsuite and skip all django-apps, the tests pass, if i comment them in, they wont run (With the above error). is there a possibility django changes the language-settings somehow within its own tests, which affect my other tests?

Melvyn Sopacua

unread,
Aug 2, 2012, 5:10:33 PM8/2/12
to django...@googlegroups.com
On 31-7-2012 21:21, Andre Schemschat wrote:

> Now, if i run all tests, not just for that specific view, the test fails,
> because the view returnes {'fielda':'This field is required.'} instead of
> the german localization. I checked the settings.LANGUAGE_CODE-value in the
> view and in the test, in both cases it is de-de.
> Any ideas, why my test is fine if it runs alone and fails when all tests of
> the project (including the django-ones) are run? Im fresh out of ideas and
> a little bit puzzled :D

On a hunch, I suspect the LOCALE_PATHS setting to be the culprit.

--
Melvyn Sopacua
Reply all
Reply to author
Forward
0 new messages