[TIP] Determine test status in tearDown method

Olemis Lang olemis at gmail.com
Tue Oct 20 10:05:29 PDT 2009

On Tue, Oct 20, 2009 at 11:28 AM, 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.

What comes to my mind is to make accessible some kind of context
object in setUp (possibly a shared fixture) containing the active
instance of test result and query for `tc in tr.failures` (perhaps not
accurate, but more or less ;o)

There may be much better workarournds ;o)



Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
Gasol in for Spain: they lead european basket  -

More information about the testing-in-python mailing list