Source

nose-pycon / doc / module_nose.plugins.manager.html

<html>
  <head>
    <title>nose: nose.plugins.manager</title>
    <link rel="stylesheet" href="site.css" type="text/css"></link>
  </head>
  <body>
    
    <div id="menu">
      <p>This document covers nose version <b>0.10.1</b></p>
      <p>Last update: <b>Fri Jan  4 10:06:23 2008</b></p>
      <h2>Plugins</h2><ul><li><a href="plugin_attrib.html">Builtin Plugin: attrib</a></li><li><a href="plugin_capture.html">Builtin Plugin: capture</a></li><li><a href="plugin_cover.html">Builtin Plugin: cover</a></li><li><a href="plugin_debug.html">Builtin Plugin: debug</a></li><li><a href="plugin_deprecated.html">Builtin Plugin: deprecated</a></li><li><a href="plugin_doctests.html">Builtin Plugin: doctests</a></li><li><a href="plugin_failuredetail.html">Builtin Plugin: failuredetail</a></li><li><a href="plugin_isolate.html">Builtin Plugin: isolate</a></li><li><a href="plugin_prof.html">Builtin Plugin: prof</a></li><li><a href="plugin_skip.html">Builtin Plugin: skip</a></li><li><a href="plugin_testid.html">Builtin Plugin: testid</a></li><li><a href="error_class_plugin.html">ErrorClass Plugins</a></li><li><a href="plugin_interface.html">Plugin Interface</a></li><li><a href="writing_plugins.html">Writing Plugins</a></li></ul><h2>Modules</h2><ul><li><a href="module_nose.case.html">Module: nose.case</a></li><li><a href="module_nose.commands.html">Module: nose.commands</a></li><li><a href="module_nose.config.html">Module: nose.config</a></li><li><a href="module_nose.core.html">Module: nose.core</a></li><li><a href="module_nose.exc.html">Module: nose.exc</a></li><li><a href="module_nose.importer.html">Module: nose.importer</a></li><li><a href="module_nose.inspector.html">Module: nose.inspector</a></li><li><a href="module_nose.loader.html">Module: nose.loader</a></li><li><a href="module_nose.plugins.manager.html">Module: nose.plugins.manager</a></li><li><a href="module_nose.plugins.plugintest.html">Module: nose.plugins.plugintest</a></li><li><a href="module_nose.proxy.html">Module: nose.proxy</a></li><li><a href="module_nose.result.html">Module: nose.result</a></li><li><a href="module_nose.selector.html">Module: nose.selector</a></li><li><a href="module_nose.suite.html">Module: nose.suite</a></li><li><a href="module_nose.tools.html">Module: nose.tools</a></li><li><a href="module_nose.twistedtools.html">Module: nose.twistedtools</a></li><li><a href="module_nose.util.html">Module: nose.util</a></li></ul><h2>Plugin Examples</h2><ul><li><a href="unwanted_package.html">Excluding Unwanted Packages</a></li><li><a href="empty_plugin.html">Minimal plugin</a></li><li><a href="init_plugin.html">Running Initialization Code Before the Test Run</a></li><li><a href="selector_plugin.html">Using a Custom Selector</a></li><li><a href="plugin_exceptions.html">When Plugins Fail</a></li><li><a href="plugintest_environment.html">nose.plugins.plugintest, os.environ and sys.argv</a></li></ul>
      <h2>Classes</h2><ul><li><a href="#DefaultPluginManager">DefaultPluginManager</a></li><li><a href="#PluginManager">PluginManager</a></li><li><a href="#EntryPointPluginManager">EntryPointPluginManager</a></li><li><a href="#BuiltinPluginManager">BuiltinPluginManager</a></li><li><a href="#RestrictedPluginManager">RestrictedPluginManager</a></li><li><a href="#PluginProxy">PluginProxy</a></li><li><a href="#ZeroNinePlugin">ZeroNinePlugin</a></li></ul>
    </div>
    
    <div id="main">
      <h1>nose: nose.plugins.manager</h1>
      
      <p>A plugin manager class is used to load plugins, manage the list of
loaded plugins, and proxy calls to those plugins.</p>
<p>The plugin managers provided with nose are:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">PluginManager</span></tt></dt>
<dd>This manager doesn't implement loadPlugins, so it can only work
with a static list of plugins.</dd>
<dt><tt class="docutils literal"><span class="pre">BuiltinPluginManager</span></tt></dt>
<dd>This manager loads plugins referenced in <tt class="docutils literal"><span class="pre">nose.plugins.builtin</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">EntryPointPluginManager</span></tt></dt>
<dd>This manager uses setuptools entrypoints to load plugins.</dd>
<dt><tt class="docutils literal"><span class="pre">DefaultPluginMananger</span></tt></dt>
<dd>This is the manager class that will be used by default. If
setuptools is installed, it is a subclass of
<tt class="docutils literal"><span class="pre">EntryPointPluginManager</span></tt> and <tt class="docutils literal"><span class="pre">BuiltinPluginManager</span></tt>; otherwise, an
alias to <tt class="docutils literal"><span class="pre">BuiltinPluginManager</span></tt>.</dd>
<dt><tt class="docutils literal"><span class="pre">RestrictedPluginManager</span></tt></dt>
<dd>This manager is for use in test runs where some plugin calls are
not available, such as runs started with <cite>python setup.py test</cite>,
where the test runner is the default unittest <tt class="docutils literal"><span class="pre">TextTestRunner</span></tt>. It
is a subclass of <tt class="docutils literal"><span class="pre">DefaultPluginManager</span></tt>.</dd>
</dl>
<div class="section">
<h1><a id="writing-a-plugin-manager" name="writing-a-plugin-manager">Writing a plugin manager</a></h1>
<p>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 <a class="reference" href="module_nose.config.html#Config">nose.config.Config</a> instance that you pass to
<tt class="docutils literal"><span class="pre">TestProgram</span></tt> (or <tt class="docutils literal"><span class="pre">main</span></tt> or <tt class="docutils literal"><span class="pre">run</span></tt>).</p>
<p>To implement your plugin loading scheme, implement <tt class="docutils literal"><span class="pre">loadPlugins()</span></tt>,
and in that method, call <tt class="docutils literal"><span class="pre">addPlugin()</span></tt> with an instance each plugin
you wish to make available. Make sure to call
<tt class="docutils literal"><span class="pre">super(self).loadPlugins()</span></tt> as well if have subclassed a manager
other than <tt class="docutils literal"><span class="pre">PluginManager</span></tt>.</p>
</div>
<h2>Classes</h2>
<p>Highlighted methods are defined in this class.</p><a name="DefaultPluginManager"></a><div class="cls section"><span class="cls name">DefaultPluginManager</span> (<a href="module_nose.plugins.manager.html#BuiltinPluginManager">BuiltinPluginManager</a>, <a href="module_nose.plugins.manager.html#EntryPointPluginManager">EntryPointPluginManager</a>)<div class="cls doc"><h3>Methods</h3><div class="method section inherited"><span class="method name">__init__<span class="args">(self, plugins=(), proxyClass=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">__iter__<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_get_plugins<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_set_plugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugin<span class="args">(self, plug)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">configure<span class="args">(self, options, config)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"><p>Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.</p>
</div></div><div class="method section inherited"><span class="method name">loadPlugins<span class="args">(self)</span></span><span class="method inherited">(inherited from BuiltinPluginManager)</span><div class="method doc"><p>Load plugins in nose.plugins.builtin</p>
</div></div><div class="method section inherited"><span class="method name">sort<span class="args">(self, cmpf=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><h3>Attributes</h3><div class="attr section inherited"><span class="attr name">entry_points</span><pre class="attr value">Default value: ((&#39;nose.plugins.0.10&#39;, None), (&#39;nose.plugins&#39;, &lt;class nose.plugins.manager.ZeroNinePlugin&gt;))</pre><div class="attr doc"></div></div><div class="attr section inherited"><span class="attr name">plugins</span><pre class="attr value">Default value: (property)</pre><div class="attr doc"><p>Access the list of plugins managed by
this plugin manager</p>
</div></div></div></div>
<a name="PluginManager"></a><div class="cls section"><span class="cls name">PluginManager</span> (object)<div class="cls doc"><p>Base class for plugin managers. Does not implement loadPlugins, so it
may only be used with a static list of plugins.</p>
<p>The basic functionality of a plugin manager is to proxy all unknown
attributes through a <tt class="docutils literal"><span class="pre">PluginProxy</span></tt> to a list of plugins.</p>
<p>Note that the list of plugins <em>may not</em> be changed after the first plugin
call.</p>
<h3>Methods</h3><div class="method section"><span class="method name">__init__<span class="args">(self, plugins=(), proxyClass=None)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">__iter__<span class="args">(self)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">_get_plugins<span class="args">(self)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">_set_plugins<span class="args">(self, plugins)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">addPlugin<span class="args">(self, plug)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">addPlugins<span class="args">(self, plugins)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">configure<span class="args">(self, options, config)</span></span><div class="method doc"><p>Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.</p>
</div></div><div class="method section"><span class="method name">loadPlugins<span class="args">(self)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">sort<span class="args">(self, cmpf=None)</span></span><div class="method doc"></div></div><h3>Attributes</h3><div class="attr section"><span class="attr name">plugins</span><pre class="attr value">Default value: (property)</pre><div class="attr doc"><p>Access the list of plugins managed by
this plugin manager</p>
</div></div></div></div>
<a name="EntryPointPluginManager"></a><div class="cls section"><span class="cls name">EntryPointPluginManager</span> (<a href="module_nose.plugins.manager.html#PluginManager">PluginManager</a>)<div class="cls doc"><p>Plugin manager that loads plugins from the <cite>nose.plugins</cite> and
<cite>nose.plugins.0.10</cite> entry points.</p>
<h3>Methods</h3><div class="method section inherited"><span class="method name">__init__<span class="args">(self, plugins=(), proxyClass=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">__iter__<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_get_plugins<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_set_plugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugin<span class="args">(self, plug)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">configure<span class="args">(self, options, config)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"><p>Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.</p>
</div></div><div class="method section"><span class="method name">loadPlugins<span class="args">(self)</span></span><div class="method doc"><p>Load plugins by iterating the <cite>nose.plugins</cite> entry point.</p>
</div></div><div class="method section inherited"><span class="method name">sort<span class="args">(self, cmpf=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><h3>Attributes</h3><div class="attr section"><span class="attr name">entry_points</span><pre class="attr value">Default value: ((&#39;nose.plugins.0.10&#39;, None), (&#39;nose.plugins&#39;, &lt;class nose.plugins.manager.ZeroNinePlugin&gt;))</pre><div class="attr doc"></div></div><div class="attr section inherited"><span class="attr name">plugins</span><pre class="attr value">Default value: (property)</pre><div class="attr doc"><p>Access the list of plugins managed by
this plugin manager</p>
</div></div></div></div>
<a name="BuiltinPluginManager"></a><div class="cls section"><span class="cls name">BuiltinPluginManager</span> (<a href="module_nose.plugins.manager.html#PluginManager">PluginManager</a>)<div class="cls doc"><p>Plugin manager that loads plugins from the list in
<cite>nose.plugins.builtin</cite>.</p>
<h3>Methods</h3><div class="method section inherited"><span class="method name">__init__<span class="args">(self, plugins=(), proxyClass=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">__iter__<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_get_plugins<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_set_plugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugin<span class="args">(self, plug)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">configure<span class="args">(self, options, config)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"><p>Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.</p>
</div></div><div class="method section"><span class="method name">loadPlugins<span class="args">(self)</span></span><div class="method doc"><p>Load plugins in nose.plugins.builtin</p>
</div></div><div class="method section inherited"><span class="method name">sort<span class="args">(self, cmpf=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><h3>Attributes</h3><div class="attr section inherited"><span class="attr name">plugins</span><pre class="attr value">Default value: (property)</pre><div class="attr doc"><p>Access the list of plugins managed by
this plugin manager</p>
</div></div></div></div>
<a name="RestrictedPluginManager"></a><div class="cls section"><span class="cls name">RestrictedPluginManager</span> (<a href="module_nose.plugins.manager.html#DefaultPluginManager">DefaultPluginManager</a>)<div class="cls doc"><p>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.</p>
<h3>Methods</h3><div class="method section"><span class="method name">__init__<span class="args">(self, plugins=(), exclude=())</span></span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">__iter__<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_get_plugins<span class="args">(self)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">_set_plugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugin<span class="args">(self, plug)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">addPlugins<span class="args">(self, plugins)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">configure<span class="args">(self, options, config)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"><p>Configure the set of plugins with the given options
and config instance. After configuration, disabled plugins
are removed from the plugins list.</p>
</div></div><div class="method section"><span class="method name">loadPlugins<span class="args">(self)</span></span><div class="method doc"></div></div><div class="method section inherited"><span class="method name">sort<span class="args">(self, cmpf=None)</span></span><span class="method inherited">(inherited from PluginManager)</span><div class="method doc"></div></div><h3>Attributes</h3><div class="attr section inherited"><span class="attr name">entry_points</span><pre class="attr value">Default value: ((&#39;nose.plugins.0.10&#39;, None), (&#39;nose.plugins&#39;, &lt;class nose.plugins.manager.ZeroNinePlugin&gt;))</pre><div class="attr doc"></div></div><div class="attr section inherited"><span class="attr name">plugins</span><pre class="attr value">Default value: (property)</pre><div class="attr doc"><p>Access the list of plugins managed by
this plugin manager</p>
</div></div></div></div>
<a name="PluginProxy"></a><div class="cls section"><span class="cls name">PluginProxy</span> (object)<div class="cls doc"><p>Proxy for plugin calls. Essentially a closure bound to the
given call and plugin list.</p>
<p>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.</p>
<h3>Methods</h3><div class="method section"><span class="method name">__call__<span class="args">(self, *arg, **kw)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">__init__<span class="args">(self, call, plugins)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">_loadTestsFromNames<span class="args">(self, names, module=None)</span></span><div class="method doc"><p>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.</p>
</div></div><div class="method section"><span class="method name">addPlugin<span class="args">(self, plugin, call)</span></span><div class="method doc"><p>Add plugin to my list of plugins to call, if it has the attribute
I'm bound to.</p>
</div></div><div class="method section"><span class="method name">chain<span class="args">(self, *arg, **kw)</span></span><div class="method doc"><p>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.</p>
</div></div><div class="method section"><span class="method name">generate<span class="args">(self, *arg, **kw)</span></span><div class="method doc"><p>Call all plugins, yielding each item in each non-None result.</p>
</div></div><div class="method section"><span class="method name">makeCall<span class="args">(self, call)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">simple<span class="args">(self, *arg, **kw)</span></span><div class="method doc"><p>Call all plugins, returning the first non-None result.</p>
</div></div></div></div>
<a name="ZeroNinePlugin"></a><div class="cls section"><span class="cls name">ZeroNinePlugin</span> ()<div class="cls doc"><p>Proxy for 0.9 plugins, adapts 0.10 calls to 0.9 standard.</p>
<h3>Methods</h3><div class="method section"><span class="method name">__init__<span class="args">(self, plugin)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">addError<span class="args">(self, test, err)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">addFailure<span class="args">(self, test, err)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">addSuccess<span class="args">(self, test)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">loadTestsFromFile<span class="args">(self, filename)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">options<span class="args">(self, parser, env=os.environ)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">startTest<span class="args">(self, test)</span></span><div class="method doc"></div></div><div class="method section"><span class="method name">stopTest<span class="args">(self, test)</span></span><div class="method doc"></div></div></div></div>

    </div>
    <script src="http://www.google-analytics.com/urchin.js" 
	    type="text/javascript">
    </script>
    <script type="text/javascript">
      _uacct = "UA-2236166-1";
      urchinTracker();
    </script>
  </body>
</html>