[TIP] (no subject)

Laura Creighton lac at openend.se
Sun Jul 1 14:20:58 PDT 2007

Subject: Re: [TIP] Best way to do setup/teardown on a per-test basis using doctest? 
In-Reply-To: Message from Titus Brown <titus at caltech.edu> 
   of "Sun, 01 Jul 2007 14:06:09 PDT." <20070701210609.GC16895 at caltech.edu> 
References: <bbaeab100706301325u30a4dabcx535b6ae477853c41 at mail.gmail.com> <20070701210609.GC16895 at caltech.edu> 
> But I am willing to give a doctest a shot.  To learn it I have a need
> to write some regression tests for __import__.  But because it is
> testing something that has a lot of file I/O I have a need to
> temporarily create some files, run the tests, and then delete the
> created files.
> I read about the Unittest API, but I would like to be able to specify
> what files to create on a per-test basis.  Normally I would use a
> try/finally or develop a context manager, but that would suppress the
> output from expression evaluation and thus kill the testing (if I
> understand how doctest works).
> So what is the best way to approach this?

If the purpose of the exercise is 'to learn doctest', then I don't
have anything useful to suggest.  But if you just want to write
some regression tests for __import__ and need a better test runner
than unittest, check out py.test or nose.

Laura Creighton

More information about the testing-in-python mailing list