[TIP] Determine test status in tearDown method

Jonathan Lange jml at mumak.net
Tue Oct 20 09:56:49 PDT 2009


On Tue, Oct 20, 2009 at 5:28 PM, Jesse Thompson <jessejlt at gmail.com> wrote:
> I'm having a difficult time figuring out how to determine a test's status
> from the tearDown method, do any of you know how I might go about doing so?
> Example: While running a test some unhandled exception is thrown, which
> causes the test to fail, I would like to know about it in the tearDown
> method. Or if a test fails due to an assertion failure, I would still like
> to know about it in tearDown so that I can attach some extra logging
> information to the test's failure output.
>

There's no public API for doing this.

I'd suggest writing a decorator that catches unexpected exceptions,
does the extra logging and then reraises.

jml



More information about the testing-in-python mailing list