[TIP] Coming changes to unittest2 plugins

Michael Foord fuzzyman at voidspace.org.uk
Mon Sep 27 10:04:23 PDT 2010


  On 27/09/2010 17:51, Eric Smith wrote:
> [Apologies if you see this (or variations on it) more than once, I'm
> having connectivity issues and I'm not sure what's been sent]
>
>> On 03:57 pm, olemis at gmail.com wrote:
>>> On Mon, Sep 27, 2010 at 11:38 AM, Michael Foord
>>> <michael at voidspace.org.uk>  wrote:
>>>>   On 27/09/2010 16:36, holger krekel wrote:
>>>>> Hi Tarek, Michael,
>>> :o)
>>>>> On Mon, Sep 27, 2010 at 16:47 +0200, Tarek Ziadé wrote:
>>>>>> On Mon, Sep 27, 2010 at 4:33 PM, Michael
>>>>>> Foord<michael at voidspace.org.uk>
>>>>>>   wrote:
>>>>>>> package.module:Class
>>>>> The advantage of this notation is that it's explicit and clear what
>>>>> is the module part and what is the object ...
>>>> Isn't the last part always the object? Or am I missing something...
>>>>
>>>> Michael
>>> Migh not always be so
>>>
>>> {{{
>>> #!
>>>
>>> class MyClass
>>>   def method1
>>>      pass
>>>   class InnerClass
>>>     def method2
>>>        pass
>>> }}}
>>>
>>> In this case AFAICR
>>>
>>> mypkg.mymdl:MyClass
>>> mypkg.mymdl:MyClass.method1
>>> mypkg.mymdl:MyClass.InnerClass
>>> mypkg.mymdl:MyClass.InnerClass.method2
>>>
>>> CMIIW
>>>
>>> PS: IMO both sides have some good reasons to choose any alternative
>>> (uniformity vs explicitness ...)
>> But this difference doesn't matter.  If someone wants to specify a
>> method of an inner class to be used as a plugin - great!  As far as I
>> can tell, unittest2 doesn't care.  The : doesn't add anything.
> It's not exactly the same, but I'm using setuptools scripts which have
> entry points defined as "a.b.c:d.e". "a.b.c" is a module, "d" is a class,
> "e" is a classmethod.
>
> The code generated by zc.recipe.egg looks like:
> import a.b.c
> a.b.c.d.e()
>
> If you don't know where the module name stops, I don't see how you'd
> generate this code.

Well, you call a function that finds it instead:

e = getObjectFromName('a.b.c.d.e')
e()

Which is exactly how unittest2 will do it. (Using 
'unittest2.util.getObjectFromName'.)

All the best,

Michael

> Again, this might not be the same case as with unittest2 plugins, but I
> don't see how you can get rid of colons in the general case in d2.
>
> Eric.
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python


-- 
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