[TIP] always call teardownX even if setupX fails?
holger at merlinux.eu
Thu Jan 28 04:10:18 PST 2010
On Thu, Jan 28, 2010 at 08:19 +1100, Robert Collins wrote:
> On Wed, 2010-01-27 at 18:07 +0100, holger krekel wrote:
> > > Any test with moderately complex external fixtures would benefit
> > from
> > > this behavior. We use a subclass of unittest.TestCase that always
> > calls
> > > tearDown() for all of our tests at Racemi.
> > thanks for your feedback. py.test will do that as well with 1.2.1 -
> > with
> > the addition that triggering "Skipped" exceptions in a setup function
> > will
> > not call teardown.
> Why not?
> self.foo = get_foo()
> if not isinstance(self.foo, TestableThing):
> raise TestSkipped()
> Why should this /not/ call tearDown ?
not calling teardown seemed slightly easier to implement ... i can work
a bit harder though :)
However, I haven't see your example pattern with py.test usages yet.
Is this a an example from actual code?
And if so do you have have and use it in setup_module and setup_class - alike
More information about the testing-in-python