The plugin system in nose2 is based on the plugin system in unittest2’s plugins branch.
Base class for nose2 plugins
All nose2 plugins must subclass this class.
The nose2.session.Session under which the plugin has been loaded.
The nose2.config.Config representing the plugin’s config section as loaded from the session’s config files.
A tuple of (short opt, long opt, help text) that defines a command line flag that activates this plugin. The short opt may be None. If defined, it must be a single upper-case character. Both short and long opt must not start with dashes.
Example:
commandLineOption = ('B', 'buffer-output', 'Buffer output during tests')
The name config file section to load into this plugin’s config.
If this plugin should automatically register itself, set alwaysOn to True. Default is False.
Note
Plugins that use config values from config files and want to use the nose2 sphinx extension to automatically generate documentation must extract all config values from self.config in __init__. Otherwise the extension will not be able to detect the config keys that the plugin uses.
Add command-line option that takes one argument.
Parameters: |
|
---|
Add command-line flag that takes no arguments
Parameters: |
|
---|
Add new plugin methods to hooks registry
Any plugins that are already registered and implement a method added here will be registered for that method as well.
Add command-line option.
Parameters: |
|
---|
Definition of plugin interface.
Instances of this class contain the methods that may be called, and a dictionary of nose2.events.Hook instances bound to each method.
In a plugin, PluginInterface instance is typically available as self.session.hooks, and plugin hooks may be called on it directly:
event = events.LoadFromModuleEvent(module=the_module)
self.session.hooks.loadTestsFromModule(event)
Tuple of methods that are called before registration.
Tuple of available plugin hook methods.
Class to instantiate for each hook. Default: nose2.events.Hook.
Add a method to the available method.
This allows plugins to register for this method.
Parameters: | method – A method name |
---|
alias of Hook
A plugin hook
Each plugin method in the nose2.events.PluginInterface is represented at runtime by a Hook instance that lists the plugins that should be called by that hook.
The name of the method that this Hook represents.
The list of plugin instances bound to this hook.