"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.

Hi all,

I had a busy weekend after posting, so didn't get a chance to follow-up until now. Thanks to all who responded.

Python's my first real language, and I am a mere hobbyist, so the suggestions for search terms provided by Terry (and implicitly by Andre who suggested a mock strategy) are most welcome! Sometimes the hardest part of googling is knowing what terms to search for.

Grig suggested the tempfile module; I had rejected that initially, as the code I am testing displays an error message containing the bad file path, so I thought I needed to know the path name at time of coding the tests. But, I've since learned that doctest can be made to consider only leading portions of a line's content. So, this might well work for me. Thanks for reminding me of the approach.

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 seeing that others have done so, too.

Anyway, thanks again for the suggestions :-)  Best to all,

Brian vdB

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to