[unittest] Run setUp only once
timothy.grant at gmail.com
Mon Aug 4 18:07:11 CEST 2008
On Sun, Aug 3, 2008 at 1:56 PM, Jorgen Grahn <grahn+nntp at snipabacken.se> wrote:
> On Tue, 29 Jul 2008 20:12:14 +0200, Nikolaus Rath <Nikolaus at rath.org> wrote:
>> Jean-Paul Calderone <exarkun at divmod.com> writes:
>>> On Tue, 29 Jul 2008 19:26:09 +0200, Nikolaus Rath <nikolaus at rath.org> wrote:
>>>>Jean-Paul Calderone <exarkun at divmod.com> writes:
>>>>> On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus Rath <nikolaus at rath.org> wrote:
>>>>>>I have a number of conceptually separate tests that nevertheless need
>>>>>>a common, complicated and expensive setup.
>>>>>>Unfortunately, unittest runs the setUp method once for each defined
>>>>>>test, even if they're part of the same class as in
>> Yeah, well, I guess that would work. But to me this looks really more
>> like a nasty hack.. isn't there a proper solution?
> [Someone described elsewhere in the thread how it's xUnit's philosophy
> to have one environment per executed test.]
> One option is to look into other unit test tools. People sometimes
> mention "py.test" as being superior. I haven't tried it -- I'm just a
> slightly dissatisfied unittest user.
> // Jorgen Grahn <grahn@ Ph'nglui mglw'nafh Cthulhu
> \X/ snipabacken.se> R'lyeh wgah'nagl fhtagn!
py.test supports setup/teardown_module, setup/teardown_class and
I've never needed to use the first, the second comes in very handy
especially when writing acceptance tests.
tjg. [Timothy Grant]
More information about the Python-list