Questions after testtools merge
Jonathan Lange
jml at canonical.com
Wed Jan 6 04:44:46 GMT 2010
On Tue, Jan 5, 2010 at 10:12 PM, Vincent Ladeuil <v.ladeuil+lp at free.fr> wrote:
>
>>>>>> "jml" == Jonathan Lange <jml at mumak.net> writes:
>
> <snip/>
>
> >>> However, if I read the above correctly, teardown is clearly called
> >>> *before* cleanups. Which doesn't quite fit with the fact that setUp is
> >>> called before addCleanup, etc.
>
> I rely on that behavior a lot and had always considered:
>
> try:
> test specific setup
> exercise SUT
> assertions
> finally:
> test specific tear down
>
> as equivalent to:
>
> test setup
> add cleanup
> exercise SUT
> assertions
>
> And as long as cleanups are called *before* tearDown, I feel
> safe. And I did the above change in many existing bzr tests.
>
> This saved me from defining a specific class with its associated
> setUp/tearDown for one test.
>
Yes, I think that cleanups before tearDown are to be preferred. I've
written addCleanup for testtools, Trial and for Launchpad, and for
each of them I put the cleanup before tearDown.
I think the Python decision is a mistake, and that the write place to
correct it is in Python. I encourage you to advocate the change,
perhaps with a patch, on the python-dev mailing list, or the
testing-in-python mailing list.
jml
More information about the bazaar
mailing list