nose: nose.plugins.manager

A plugin manager class is used to load plugins, manage the list of loaded plugins, and proxy calls to those plugins.

The plugin managers provided with nose are:

PluginManager
This manager doesn't implement loadPlugins, so it can only work with a static list of plugins.
BuiltinPluginManager
This manager loads plugins referenced in nose.plugins.builtin.
EntryPointPluginManager
This manager uses setuptools entrypoints to load plugins.
DefaultPluginMananger
This is the manager class that will be used by default. If setuptools is installed, it is a subclass of EntryPointPluginManager and BuiltinPluginManager; otherwise, an alias to BuiltinPluginManager.
RestrictedPluginManager
This manager is for use in test runs where some plugin calls are not available, such as runs started with python setup.py test, where the test runner is the default unittest TextTestRunner. It is a subclass of DefaultPluginManager.

Writing a plugin manager

If you want to load plugins via some other means, you can write a plugin manager and pass an instance of your plugin manager class when instantiating the nose.config.Config instance that you pass to TestProgram (or main or run).

To implement your plugin loading scheme, implement loadPlugins(), and in that method, call addPlugin() with an instance each plugin you wish to make available. Make sure to call super(self).loadPlugins() as well if have subclassed a manager other than PluginManager.

Classes

Highlighted methods are defined in this class.

DefaultPluginManager (BuiltinPluginManager, EntryPointPluginManager)

Methods

__init__(self, plugins=(), proxyClass=None)(inherited from PluginManager)
__iter__(self)(inherited from PluginManager)
_get_plugins(self)(inherited from PluginManager)
_set_plugins(self, plugins)(inherited from PluginManager)
addPlugin(self, plug)(inherited from PluginManager)
addPlugins(self, plugins)(inherited from PluginManager)
configure(self, options, config)(inherited from PluginManager)

Configure the set of plugins with the given options and config instance. After configuration, disabled plugins are removed from the plugins list.

loadPlugins(self)(inherited from BuiltinPluginManager)

Load plugins in nose.plugins.builtin

sort(self, cmpf=None)(inherited from PluginManager)

Attributes

entry_points
Default value: (('nose.plugins.0.10', None), ('nose.plugins', <class nose.plugins.manager.ZeroNinePlugin>))
plugins
Default value: (property)

Access the list of plugins managed by this plugin manager

PluginManager (object)

Base class for plugin managers. Does not implement loadPlugins, so it may only be used with a static list of plugins.

The basic functionality of a plugin manager is to proxy all unknown attributes through a PluginProxy to a list of plugins.

Note that the list of plugins may not be changed after the first plugin call.

Methods

__init__(self, plugins=(), proxyClass=None)
__iter__(self)
_get_plugins(self)
_set_plugins(self, plugins)
addPlugin(self, plug)
addPlugins(self, plugins)
configure(self, options, config)

Configure the set of plugins with the given options and config instance. After configuration, disabled plugins are removed from the plugins list.

loadPlugins(self)
sort(self, cmpf=None)

Attributes

plugins
Default value: (property)

Access the list of plugins managed by this plugin manager

EntryPointPluginManager (PluginManager)

Plugin manager that loads plugins from the nose.plugins and nose.plugins.0.10 entry points.

Methods

__init__(self, plugins=(), proxyClass=None)(inherited from PluginManager)
__iter__(self)(inherited from PluginManager)
_get_plugins(self)(inherited from PluginManager)
_set_plugins(self, plugins)(inherited from PluginManager)
addPlugin(self, plug)(inherited from PluginManager)
addPlugins(self, plugins)(inherited from PluginManager)
configure(self, options, config)(inherited from PluginManager)

Configure the set of plugins with the given options and config instance. After configuration, disabled plugins are removed from the plugins list.

loadPlugins(self)

Load plugins by iterating the nose.plugins entry point.

sort(self, cmpf=None)(inherited from PluginManager)

Attributes

entry_points
Default value: (('nose.plugins.0.10', None), ('nose.plugins', <class nose.plugins.manager.ZeroNinePlugin>))
plugins
Default value: (property)

Access the list of plugins managed by this plugin manager

BuiltinPluginManager (PluginManager)

Plugin manager that loads plugins from the list in nose.plugins.builtin.

Methods

__init__(self, plugins=(), proxyClass=None)(inherited from PluginManager)
__iter__(self)(inherited from PluginManager)
_get_plugins(self)(inherited from PluginManager)
_set_plugins(self, plugins)(inherited from PluginManager)
addPlugin(self, plug)(inherited from PluginManager)
addPlugins(self, plugins)(inherited from PluginManager)
configure(self, options, config)(inherited from PluginManager)

Configure the set of plugins with the given options and config instance. After configuration, disabled plugins are removed from the plugins list.

loadPlugins(self)

Load plugins in nose.plugins.builtin

sort(self, cmpf=None)(inherited from PluginManager)

Attributes

plugins
Default value: (property)

Access the list of plugins managed by this plugin manager

RestrictedPluginManager (DefaultPluginManager)

Plugin manager that restricts the plugin list to those not excluded by a list of exclude methods. Any plugin that implements an excluded method will be removed from the manager's plugin list after plugins are loaded.

Methods

__init__(self, plugins=(), exclude=())
__iter__(self)(inherited from PluginManager)
_get_plugins(self)(inherited from PluginManager)
_set_plugins(self, plugins)(inherited from PluginManager)
addPlugin(self, plug)(inherited from PluginManager)
addPlugins(self, plugins)(inherited from PluginManager)
configure(self, options, config)(inherited from PluginManager)

Configure the set of plugins with the given options and config instance. After configuration, disabled plugins are removed from the plugins list.

loadPlugins(self)
sort(self, cmpf=None)(inherited from PluginManager)

Attributes

entry_points
Default value: (('nose.plugins.0.10', None), ('nose.plugins', <class nose.plugins.manager.ZeroNinePlugin>))
plugins
Default value: (property)

Access the list of plugins managed by this plugin manager

PluginProxy (object)

Proxy for plugin calls. Essentially a closure bound to the given call and plugin list.

The plugin proxy also must be bound to a particular plugin interface specification, so that it knows what calls are available and any special handling that is required for each call.

Methods

__call__(self, *arg, **kw)
__init__(self, call, plugins)
_loadTestsFromNames(self, names, module=None)

Chainable but not quite normal. Plugins return a tuple of (tests, names) after processing the names. The tests are added to a suite that is accumulated throughout the full call, while names are input for the next plugin in the chain.

addPlugin(self, plugin, call)

Add plugin to my list of plugins to call, if it has the attribute I'm bound to.

chain(self, *arg, **kw)

Call plugins in a chain, where the result of each plugin call is sent to the next plugin as input. The final output result is returned.

generate(self, *arg, **kw)

Call all plugins, yielding each item in each non-None result.

makeCall(self, call)
simple(self, *arg, **kw)

Call all plugins, returning the first non-None result.

ZeroNinePlugin ()

Proxy for 0.9 plugins, adapts 0.10 calls to 0.9 standard.

Methods

__init__(self, plugin)
addError(self, test, err)
addFailure(self, test, err)
addSuccess(self, test)
loadTestsFromFile(self, filename)
options(self, parser, env=os.environ)
startTest(self, test)
stopTest(self, test)