"Virtual" file system mock object - replacing stuff in__builtins__

Terry Reedy tjreedy at udel.edu
Tue Mar 9 14:06:58 EST 2004


"Remy Blank" <remy.blank_asps at pobox.com> wrote in message
news:404dfe36$1 at epflnews.epfl.ch...
> John Roth wrote:
> > Yes. It's never a good idea to replace stuff on the system
> > level, and some day it might become impossible.
>
> That's too bad. When test-driving code in C++, you have to use an
> abstraction layer between your code and the file system accessors, to be
> able to replace it by a mock object for testing. I always thought it was
> an advantage of Python to be able to use the "native" calls and still
> replace them by stubs for testing purposes.

If I understand you correctly, you could put everything meant to
replace/mask constants/functions in the builtins in test_builtins.py and
'from test_builtins import *' or explicitly import a subset as appropriate.

 Terry J. Reedy







More information about the Python-list mailing list