[TIP] Coming changes to unittest2 plugins

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Tue Sep 28 13:41:51 PDT 2010

On 07:57 pm, olemis at gmail.com wrote:
>On Mon, Sep 27, 2010 at 8:36 PM,  <exarkun at twistedmatrix.com> wrote:
>>On 27 Sep, 07:42 pm, holger at merlinux.eu wrote:
>>>On Mon, Sep 27, 2010 at 19:19 -0000, exarkun at twistedmatrix.com wrote:
>>>>>packaging meta data is for consumption of tools.  For example, i 
>>>>>want to
>>>>>write one that converts a newstyle setup.cfg into an oldstyle 
>>>>What transformation do you need to perform on an arbitrary, 
>>>>specified fully qualified Python name?  In general you can't know
>>>>anything about it, whether it has a ":" in it or not.
>>>Wrong. The ":" carries information.  For example, if we have:
>>>  [global]
>>>  script-entry-points =
>>>      somescript = testpath.to:some.function
>>>we can easily generate an oldstyle setup.py from it:
>>>  setup(entry_points={'somescript': 'testpath.to:some.function'}, 
>>>without having to load live objects.  The dotted name does
>>>not allow that and thus carries less information.
>>Thanks for explaining that.  This is clearly a case where the ":" 
>>helps (a
>>sort of self-referential case, where the ":" is only needed because it 
>>to be needed).
>>It's not an important case to me (and I don't think it should be 
>>to anyone else).  It's still nice to know *why* the ":" might be 
>What d'u think of the example I mentioned before (i.e. the Trac plugin
>(macro?)  for the lazy dev ...) ???

This one?
>However, suppose I'm developing some apps (each one under top-level
>folder in VCS) adding unittest plugins and I want to develop a Trac
>plugin (macro ?) that will know the path to top-level folder in VCS
>and will look for unittest metadata definition inside setup.* (or
>wherever it might be defined ...) of all direct descendants (i.e.
>folders). With this data it will render inside a floating div some
>links to Trac repository browser area (e.g. highlighting the lines
>where the plugin code is located) . That would allow me to quickly
>find plugin code inside e.g. repository browser and wiki pages (/me
>the lazy dev ) .

I have a little difficulty following it.  That said, unless I've gravely 
misunderstood, it sounds like you can implement it without ":" just 
about as easily as with.  Given "foo.bar.baz" look for foo/bar/baz.py. 
Exists?  Great, you're done.  Otherwise look for foo/bar.py.  Otherwise 
look for foo.py.

It'll be wrong sometimes, but so will assuming that "foo.bar:baz" means 
to look in foo/bar.py.  Without loading the code you can't be completely 
sure (and maybe even if you load the code you'll still get it wrong 
sometimes, I'm not sure).


More information about the testing-in-python mailing list