[TIP] Determine test status in tearDown method

Olemis Lang olemis at gmail.com
Tue Oct 20 10:22:17 PDT 2009


On Tue, Oct 20, 2009 at 11:56 AM, Jonathan Lange <jml at mumak.net> wrote:
> 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,

possibly, yes

> does the extra logging and then reraises.
>

IMO should be to store the exc object in the test case instance itself
(but that depends on the circumstances ;o)

-- 
Regards,

Olemis.

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

Featured article:
Gasol in for Spain: they lead european basket  -
http://feedproxy.google.com/~r/simelo-en/~3/QnrH66KHXHk/gasol-in-for-spain-they-lead-european.html



More information about the testing-in-python mailing list