testing -- what to do for testing code with behaviour dependant upon which files exist?
Terry Reedy
tjreedy at udel.edu
Sun Apr 3 01:58:59 EST 2005
"Brian van den Broek" <bvande at po-box.mcgill.ca> wrote in message
news:424F00D5.9020205 at po-box.mcgill.ca...
> Hi all,
>
> I'm just starting to employ unit testing (I'm using doctest), and I am
> uncertain how to handle writing tests where the behaviour being tested is
> dependant on whether certain file paths point to actual files.
I would think about writing a dummy 'file' function whose return or raising
depends on the filename passed in. Then your test would be independent of
the actual environment. For something more elaborate, I would google
Google's Python newgroup archive for 'dummy filesystem' for past threads on
the topic.
TJR
More information about the Python-list
mailing list