[TIP] Testing locale-dependent behaviour
Michael Foord
fuzzyman at voidspace.org.uk
Tue Nov 25 04:35:31 PST 2008
Alexandre Fayolle wrote:
> Le Tuesday 25 November 2008 09:52:59 Thomas Lotze, vous avez écrit :
>
>> Alexandre Fayolle wrote:
>>
>>> From what you describe, the availability of a given set of locales looks
>>> like a dependency for your test, in the same way that you might have a
>>> dependency on some third party python modules for your tests to run, or
>>> on some external software configuration (directory layout, some server
>>> listening on a TCP port...) :
>>>
>> This sounds reasonable. However, as a follow-up question, is there any way
>> of making a certain locale available (or pretending it was available) to a
>> test from within the testing process or test setup environment? I'm
>> comparing the situation to the possibility to install a server locally
>> into the test environment using zc.buildout, or to create a specifically
>> layed-out directory tree in the test setup. So is there a way to make sure
>> of a given locale other than to have someone with root access install it
>> system-wide, on every machine that might eventually run the test?
>>
>
> AFAIK, no, at least not in an OS-independent way. My box runs GNU/Linux, so
> the following might be relevant for other OSes, but no guarantee there.
>
> You may want to read locale-gen(8), locale.gen(5), localedef(1) : it looks
> like you can install locales in an arbitrary path. Then it becomes a matter
> of telling setlocale(3) where to find the file you've defined. A quick
> reading of the above manpages didn't show anything, but I could easily have
> missed it. You may have to read glibc's source.
>
> Good luck (and please report back if you find how to do this, I'm sure it will
> be appreciated)
>
Our functional test suite (Windows) changes the machine locale in a
couple of places (and changes it back again of course) to regression
tests problems we had with specific locales (usually Unicode errors I
think). I don't have the details to hand, but could get them if it would
be useful.
Michael Foord
> ------------------------------------------------------------------------
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
>
--
http://www.ironpythoninaction.com/
More information about the testing-in-python
mailing list