unittest: How to fail if environment does not allow execution?

Kent Johnson kent at kentsjohnson.com
Thu May 11 13:48:49 CEST 2006


Kai Grossjohann wrote:
> I wrote a test case that depends on a certain file existing in the
> environment.  So, I guess I should test that the file exists in the
> setUp method.  But what if it doesn't exist?  How do I fail in that case?
> 
> I would like to emit an error message explaining what is wrong.

I would just use the file normally in the test. If it's not there you 
will get an IOError with a traceback and a helpful error message.

Kent



More information about the Python-list mailing list