[TIP] Testing locale-dependent behaviour

Alexandre Fayolle alexandre.fayolle at logilab.fr
Tue Nov 25 04:25:22 PST 2008

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) 

Alexandre Fayolle                              LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Informatique scientifique:               http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: This is a digitally signed message part.
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20081125/6f9b2dc5/attachment.pgp 

More information about the testing-in-python mailing list