Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-04 Thread Brian van den Broek
Brian van den Broek [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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.

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-04 Thread Jeremy Bowers
On Mon, 04 Apr 2005 17:02:20 -0400, Brian van den Broek wrote: Jeremy suggested using a directory name akin to C:\onlyanidiotwouldhavethisdirecotrynameonadrive. That is what I had settled on before I posted. Somehow it feels unhappy and inelegant. But, I'm a bit less uncomfortable with it

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-04 Thread Brian van den Broek
Jeremy Bowers said unto the world upon 2005-04-04 17:26: On Mon, 04 Apr 2005 17:02:20 -0400, Brian van den Broek wrote: Jeremy suggested using a directory name akin to C:\onlyanidiotwouldhavethisdirecotrynameonadrive. That is what I had settled on before I posted. Somehow it feels unhappy and

testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Brian van den Broek
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 have a class which takes, in its __init__, a list of file paths to process.

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Andr Malo
* Brian van den Broek wrote: The relevant part of the validation method code looks like: # self.universe_files is a list of file paths non_existent_files = [ x for x in self.universe_files if not os.path.isfile(x) ] if

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Grig Gheorghiu
Can't you use the tempfile module to generate unique names for non-existent files and directories? Take a look at http://www.python.org/doc/lib/module-tempfile.html -- it works on all supported platforms. Grig -- http://mail.python.org/mailman/listinfo/python-list

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Jeremy Bowers
On Sat, 02 Apr 2005 15:30:13 -0500, Brian van den Broek wrote: So, how does one handle such cases with tests? When I had a similar situation, I created a directory for testing that was in a known state, and tested on that. If you can test based on a relative directory, that should work OK.

Re: testing -- what to do for testing code with behaviour dependant upon which files exist?

2005-04-02 Thread Terry Reedy
Brian van den Broek [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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