[TIP] testing unittest2 plugin branch Was: How to get coverage.py and unittest2 working together?

Michael Foord fuzzyman at voidspace.org.uk
Wed Jul 28 14:29:53 PDT 2010

On 28/07/2010 21:49, Jorge Vargas wrote:
> On Thu, Jul 22, 2010 at 6:24 PM, Michael Foord
> <fuzzyman at voidspace.org.uk>  wrote:
>> On 22/07/2010 21:02, Tim Hatch wrote:
>> For what it's worth I'm now prototyping the extension mechanism for
>> unittest/unittest2. Anyone who wants to follow along can look at the
>> "plugins" branch of the repository at http://hg.python.org/unittest2
>> It is still early days - only 3 extension points and 4 example plugins.
>> coverage is one of the example plugins I will be looking at implementing in
>> order to ensure that the plugin mechanism is adequate. Not done yet
>> though...
> Today I got it working without troubles. Well one little thing. Seems
> like the alwaysOn logic is a bit confused, as it's trying to access a
> variable that isn't set yet, the following patch will fix it.
> diff -r a5b8d976c89a unittest2/events.py
> --- a/unittest2/events.py	Wed Jul 28 17:29:44 2010 +0100
> +++ b/unittest2/events.py	Wed Jul 28 14:48:48 2010 -0600
> @@ -263,6 +263,7 @@
>               instance.config = getConfig(configSection)
>               alwaysOn = instance.config.as_bool('always-on', default=False)
> +        instance._registered = False
>           if alwaysOn:
>               instance.register()
>           else:
> @@ -270,7 +271,6 @@
>                   opt, longOpt, help_text = commandLineSwitch
>                   addOption(instance.register, opt, longOpt, help_text)
> -        instance._registered = False
>           return instance
>       def register(self):
Thanks - as I'm prototyping this it isn't tested yet - as you can tell. 
This is fixed though. It is nearly in a condition where I can write it 
up for this mailing list and python-dev. I expect it to still change, 
but I've been discussing it with Jason Pellerin who reports that the 
system is basically fine for "nose2" and he is porting a couple of the 
nose plugins to it. I'm very interested in feedback.

All the best,

Michael Foord


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