[TIP] unittest2 plugins
Michael Foord
fuzzyman at voidspace.org.uk
Mon Jul 26 08:26:35 PDT 2010
On 26/07/2010 16:22, jason pellerin wrote:
>> So you want plugins to have the ability to *change* the exception that is
>> raised? It shouldn't be very hard to modify onTestFail to do this - perhaps
>> a .exception attribute on the event.
>>
> Ideally I want plugins to be able to completely handle an exception,
> in the same way that the test result does. Everything from outputting
> a dot marker (like s or E or F or whatever they want) during testing
> and an error list at the end to determining whether seeing that
> exception means the test has failed. I want not so much to change the
> exception that is raised, but to change how it is handled. So, less
> "see an IOError, raise a SkipTest" but more "treat an IOError like a
> SkipTest".
>
> Maybe it will be more clear if I explain that I mean "treat as skip"
> not in the sense of "raise a SkipTest" but of "do the same general
> things that the result does with a skip: output a different dot, do
> not fail the test".
>
In general that can already be done. Use the events to *completely*
handle the reporting and ignore the test result. Use a test runner that
doesn't output anything and do the test reporting based on the events.
In other words I would like to deprecate the test result altogether
eventually...
The events already there should give you *all* the information you need
to do this. testStart and testStop events should tell you everything you
need to know about successes and failures. Is there any information missing?
All the best,
Michael
>
>> If this is set to None the exception is not reraised and the test becomes a
>> pass. If it is changed to a *different* exception, which could include
>> SkipTest of course, then this will be raised instead.
>>
>> Would this work for you?
>>
> Almost. That would allow some special handling of exceptions, but
> without feedback to the user about what happened.
>
> JP
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
More information about the testing-in-python
mailing list