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

Lothar Scholz llothar at web.de
Sat Mar 6 01:20:44 CET 2004


Remy Blank <remy.blank_asps at pobox.com> wrote in message news:<404844e3$1 at epflnews.epfl.ch>...

> As a fan of TDD (test-driven development), I use the unittest module to 
> write the test cases for these tools. However, to make the test cases 
> independent of the file system environment, I simulate a file system 
> tree with a mock object using the following technique (sorry for the 
> long posting):

Setup a test directory with data files and in the setUp method copy
the items from the directory to a temporary directory. Do the tests
with the temporary directory and remove it in the tearDown method.

This is the simplest case to avoid strange effects.



More information about the Python-list mailing list