Questions after testtools merge
John Arbash Meinel
john at arbash-meinel.com
Tue Jan 5 14:31:44 GMT 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
...
>
> jml> Actually, other than the mistaken docstring, it seems to
> jml> make the behaviour pretty clear. I'd be happy to make
> jml> some improvements if you can think of any.
>
> Thinking more about it, I don't think it's clear at all, I first
> thought that cleanups should only be called before tearDown but I
> realized that what I really want is a clean unwinding of setups
> that can't be implemented properly by separating cleanups and
> tear downs as they are today.
>
> On the surface, calling cleanups first addresses my point above but
> more involved configurations can require that cleanups and
> teardowns calls are intermixed and that would certainly makes
> things harder to understand for little gain.
>
> Still, as Martin showed, it's quite easy to fall in subtle traps
> when cleanups are called *after* tearDown and the only safe way
> to use cleanups it to never mix them with setups... quite hard to
> get right.
>
> Apart from the environment variables example, it means that you
> can't use tearDown to delete a test directory and use cleanups to
> delete files in that directory: 1) they are already gone, 2) You
> can't check in tearDown that test aren't leaking anymore, 3)
> tearDown should be ready to delete a non-empty directory.
Yeah, that was my conclusion as well. If you want LIFO cleanup, you need
a single queue. And addCleanup is a lot nicer than the tearDown api.
...
> Should we continue the discussion and provide more examples or
> even (gasp, tests :) or is it already a firm decision ?
>
If you want to change it, then it should be changed in python upstream.
Otherwise having testtools diverge from py 2.7 is just a sore point of
confusion.
> If you want to keep cleanups called after tear downs, can we
> discuss *another* feature where code can be called *before*
> tearDown (or at the beginning of tearDown ) ?
>
> Vincent
>
> P.S.: bzrlib.test.TestCase still defines a 'cleanups' attribute
> that we want to delete as some future... cleanup ? :D
>
I think just deprecating tearDown entirely is reasonable.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAktDTU8ACgkQJdeBCYSNAAM1LwCeP2wj5MLD5ibAob8HqiOosKBj
c5YAnRAX63Yp80/00HbaAWvl52gF7TFt
=3Hyz
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list