[TIP] unittest2 plugins

Michael Foord fuzzyman at voidspace.org.uk
Mon Jul 26 08:12:53 PDT 2010


On 26/07/2010 16:06, jason pellerin wrote:
>> As for handling custom outcomes using skiptest... Currently the onTestFail
>> event is not raised for skips, expected failures or unexpected successes.
>>      
> I'm afraid my explanation wasn't very good. This is actually the
> opposite (in a sense) of the functionality that's missing. What nose
> can do with custom error classes is allow a plugin to treat *any*
> exception like a skip. That is, say your app under test may see
> IOErrors from a 3rd party service and you don't want those tests to
> fail, you want to essentially skip them under a different label. With
> nose you can register a handler for IOError and make it treat those as
> skips instead of errors, and also output something different in the
> dots. I don't see a way to do that with the current set of hooks in
> unittest2.
>
> I hope that's more clear?
>
>    

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.

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?

Michael

> 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