"Virtual" file system mock object - replacing stuff in __builtins__

Peter Hansen peter at engcorp.com
Thu Mar 11 04:46:22 CET 2004

Remy Blank wrote:
> Peter Hansen wrote:
>> Nevertheless, if you are really doing things in a test-driven fashion, 
>> it should not be necessary to use __builtins__, if the open() calls 
>> and such are in your own code.  
> That's a good approach when testing a single module. However, when 
> testing multiple collaborating modules, doesn't it become difficult to 
> ensure that all modules see the same stub functions? 

Yes, it does become difficult then, which is why I added the last clause 
in my paragraph above...

I've resorted to sticking stuff in __builtin__ as well (note, not 
__builtins__) when faced with testing code that calls other modules 
which use open() etc...


More information about the Python-list mailing list