[TIP] Testing locale-dependent behaviour

Kathryn Van Stone kvs at acm.org
Tue Nov 25 11:35:35 PST 2008

On Nov 25, 2008, at 2:12 PM, Grig Gheorghiu wrote:

> It seems to me that your scenario is a good candidate for mock  
> testing. You could try mocking the functions that interface with  
> the locale, both by having them return canned values corresponding  
> to a given locale (and seeing how your code reacts to those  
> values), and by having them raise exceptions or other errors, to  
> simulate environments where a given locale is not present.
> Grig
I agree. In particular you don't  need to test that the locale code  
works, just that you are calling it correctly.  Mocks are good for  
that, and Python is an easy language to do mocks in.

-Kathy  Van Stone

More information about the testing-in-python mailing list