[Python-Dev] proto-pep: plugin proposal (for unittest)
Tarek Ziadé
ziade.tarek at gmail.com
Fri Jul 30 12:09:30 CEST 2010
On Fri, Jul 30, 2010 at 12:55 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
...
>
> The Plugin Class
> ================
>
> A sometimes-more-convenient way of creating plugins is to subclass the
> ``unittest2.events.Plugin`` class. By default subclassing ``Plugin`` will
> auto-instantiate the plugin and store the instance in a list of loaded
> plugins.
>
> Each plugin has a ``register()`` method that auto-hooks up all methods whose
> names correspond to events. Plugin classes may also provide
> ``configSection`` and ``commandLineSwitch`` class attributes which
> simplifies enabling the plugin through the command line and making available
> a section from the configuration file(s).
What about using ABCs here instead ? The big advantage is that you don't force
people to subclass your Plugin base class, and you get a registration
mechanism for free.
They would be able to explicitly register any class using :
from unittest2.events import Plugin
Plugin.register(MySuperPlugin)
Regards
Tarek
--
Tarek Ziadé | http://ziade.org
More information about the Python-Dev
mailing list