Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/nose/plugins/manager.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�9�c@s�dZddlZddlZddlZddlZddlmZddlm	Z	ddl
Zddlm
Z
ddlmZddlmZyddlZWnddlZnXyddlmZWnddlmZnXd	d
ddd
gZeje�Zdefd��YZdefd��YZd
efd��YZddd��YZdefd��YZdefd��YZ y)ddl!Z!d	ee fd��YZ"Wn'e#k
r�d	e fd��YZ"nXd
e"fd��YZ$dS(s
Plugin 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:

:class:`PluginManager`
    This manager doesn't implement loadPlugins, so it can only work
    with a static list of plugins.

:class:`BuiltinPluginManager`
    This manager loads plugins referenced in ``nose.plugins.builtin``.

:class:`EntryPointPluginManager`
    This manager uses setuptools entrypoints to load plugins.

:class:`ExtraPluginsPluginManager`
    This manager loads extra plugins specified with the keyword
    `addplugins`.

:class:`DefaultPluginMananger`
    This is the manager class that will be used by default. If
    setuptools is installed, it is a subclass of
    :class:`EntryPointPluginManager` and :class:`BuiltinPluginManager`;
    otherwise, an alias to :class:`BuiltinPluginManager`.

:class:`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 :class:`TextTestRunner`. It
    is a subclass of :class:`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 :class:`nose.config.Config` instance that you pass to
:class:`TestProgram` (or :func:`main` or :func:`run`).

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

i�N(tchain(twarn(tFailure(tIPluginInterface(t	sort_list(tStringIOtDefaultPluginManagert
PluginManagertEntryPointPluginManagertBuiltinPluginManagertRestrictedPluginManagertPluginProxycBs_eZdZeZd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	d�Z
RS(
s#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.
    cCs�yt|j|�|_Wn-tk
rHtd||jjf��nX|j|�|_g|_x|D]}|j||�qkWdS(Ns%s is not a valid %s method(	tgetattrt	interfacetmethodtAttributeErrort__name__tmakeCalltcalltpluginst	addPlugin(tselfRRtp((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt__init__Ws
	
cOs|j||�S(N(R(Rtargtkw((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt__call__bscs~t||d�}|dk	rz|dkrattj|�d�dkra|��fd�}n|jj||f�ndS(s`Add plugin to my list of plugins to call, if it has the attribute
        I'm bound to.
        tloadTestsFromModuleiics
�|�S(N((tmoduletpathtkwargs(t	orig_meth(s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt<lambda>nsN(RtNonetlentinspectt
getargspecRtappend(RtpluginRtmeth((Rs8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRescs_|dkr�jS�j}t|dt�r;�fd�St|dt�rT�jS�jSdS(NtloadTestsFromNamest
generativecst�j||��S(N(tlisttgenerate(RR(R(s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR {st	chainable(t_loadTestsFromNamesRRtFalseRtsimple(RRR'((Rs8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRqs	
cOs�d}gtt|jdg�|�D]\}}|r%|^q%}x:|jD]/\}}|||�}|}|j|�qMW|S(s�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.
        tstatic_argsN(R!tzipRRRR%(RRRtresulttstatictaRR'((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�s(cos�x�|jD]�\}}d}y8|||�}|dk	rSx|D]}|VqAWnWq
ttfk
rp�q
tj�}t|�Vq
q
Xq
WdS(sFCall all plugins, yielding each item in each non-None result.
        N(RR!tKeyboardInterruptt
SystemExittsystexc_infoR(RRRRR'R2trtexc((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR+�s
cOs=x6|jD]+\}}|||�}|dk	r
|Sq
WdS(s?Call all plugins, returning the first non-None result.
        N(RR!(RRRRR'R2((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR/�scCsmg}xZ|jD]O\}}||d|�}|dk	r|\}}|r_|j|�q_qqW||fS(s
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.
        RN(RR!textend(RtnamesRtsuiteRR'R2t
suite_part((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR-�sN(Rt
__module__t__doc__RR
RRRRRR+R/R!R-(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRNs							t	NoPluginscBsneZdZeZd�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�ZRS(s(Null Plugin manager that has no plugins.cCsd|_|_dS(N((t_pluginsR(R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�scCsdS(N(((R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt__iter__�scOsdS(N((Rtargstkwds((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt
_doNothing�scOsdS(N(((RRDRE((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt_emptyIterator�scCs6t|j|�}t|dt�r+|jS|jSdS(NR)(RR
R.RGRF(RRR((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt__getattr__�scCs
t��dS(N(tNotImplementedError(Rtplug((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�scCs
t��dS(N(RI(RR((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt
addPlugins�scCsdS(N((Rtoptionstconfig((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt	configure�scCsdS(N((R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pytloadPlugins�scCsdS(N((R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pytsort�s(RR?R@RR
RRCRFRGRHRRKRNRORP(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRA�s									cBs�eZdZeZdd
d�Zd�Zd�Zd�Z	ddd�Z
d�Zd�Zd�Z
d	�Zd
�Zeeed
d�ZRS(s�Base class for plugin managers. PluginManager is intended to be
    used only with a static list of plugins. The loadPlugins() implementation
    only reloads plugins from _extraplugins to prevent those from being
    overridden by a subclass.

    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.
    cCsMg|_d|_i|_|r1|j|�n|dk	rI||_ndS(N((RBt
_extrapluginst_proxiesRKR!t
proxyClass(RRRS((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�s			cCsIy|j|SWn3tk
rD|j||j�}||j|<nX|S(N(RRtKeyErrorRSRB(RRtproxy((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRH�s
cCs
t|j�S(N(titerR(R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRCscCsat|dt��}g|jD]$}t|dd�|kr|^q|j(|jj|�dS(Ntname(RtobjectRBR!R%(RRJtnew_nameR((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRs(cCs4||_x$t||�D]}|j|�qWdS(s�extraplugins are maintained in a separate list and
        re-added by loadPlugins() to prevent their being overwritten
        by plugins added by a subclass of PluginManager
        N(RQt	iterchainR(RRtextrapluginsRJ((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRKs	cCs�tjd�||_td|j�}|||�g|jD]}|jr?|^q?}||_|j�tjd|�dS(s�Configure the set of plugins with the given options
        and config instance. After configuration, disabled plugins
        are removed from the plugins list.
        sConfiguring pluginsRNsPlugins enabled: %sN(tlogtdebugRMRRBtenabledRRP(RRLRMtcfgRJR^((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRNs
	
%	
cCs%x|jD]}|j|�q
WdS(N(RQR(RRJ((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRO"scCst|jd�dt�S(NcSst|dd�S(Ntscorei(R(tx((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR 'streverse(RRBtTrue(R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRP&scCs|jS(N(RB(R((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt_get_plugins)scCsg|_|j|�dS(N(RBRK(RR((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt_set_plugins,s	sPAccess the list of plugins managed by
                       this plugin manager(N(((RR?R@RRSR!RRHRCRRKRNRORPRdRetpropertyR(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�s										tZeroNinePlugincBseeZdZd�Zejd�Zd�Zd�Zd�Z	d�Z
d�Zd�Zd	�Z
RS(
s>Proxy for 0.9 plugins, adapts 0.10 calls to 0.9 standard.
    cCs
||_dS(N(R&(RR&((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR8scCs|jj||�dS(N(R&tadd_options(Rtparsertenv((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRL;sc	Cs�t|jd�sdSddlm}m}|\}}}t||�rst|jd�s`dS|jj|j�St||�r�t|jd�s�dS|jj|j�S|j	}|jj
|j||�S(NtaddErrori�(tSkipTesttDeprecatedTesttaddSkipt
addDeprecated(thasattrR&tnose.excRlRmt
issubclassRnttestRotcapturedOutputRk(	RRsterrRlRmtectevttbtcapt((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRk>s	cCs&t|jd�r"|jj|�SdS(NtloadTestsFromPath(RpR&Rz(Rtfilename((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pytloadTestsFromFilePscCsDt|jd�sdS|j}|j}|jj|j|||�S(Nt
addFailure(RpR&RtttbinfoR}Rs(RRsRuRyR~((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR}Ts
		cCs9t|jd�sdS|j}|jj|j|�dS(Nt
addSuccess(RpR&RtRRs(RRsRy((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR\s	cCs)t|jd�sdS|jj|j�S(Nt	startTest(RpR&R�Rs(RRs((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�bscCs)t|jd�sdS|jj|j�S(NtstopTest(RpR&R�Rs(RRs((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�gscCst|j|�S(N(RR&(Rtval((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRHls(RR?R@RtostenvironRLRkR|R}RR�R�RH(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRg5s							cBs)eZdZddeffZd�ZRS(shPlugin manager that loads plugins from the `nose.plugins` and
    `nose.plugins.0.10` entry points.
    snose.plugins.0.10snose.pluginsc	Csddlm}i}x�jD]�\}}x�||�D]�}|j|krTq9nt||j<tjd|jj|�y|j	�}Wn@t
k
r��n-tk
r�}td||ft
�q9nX|r�|��}n	|�}|j|�q9Wq Wtt|�j�dS(sBLoad plugins by iterating the `nose.plugins` entry point.
        i�(titer_entry_pointss%s load plugin %ssUnable to load plugin %s: %sN(t
pkg_resourcesR�tentry_pointsRWRcR\R]t	__class__RtloadR5t	ExceptionRtRuntimeWarningRtsuperRRO(	RR�tloadedtentry_pointtadaptteptplugclsteRJ((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyROws*

	N(snose.plugins.0.10N(RR?R@R!RgR�RO(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRpscBseZdZd�ZRS(sSPlugin manager that loads plugins from the list in
    `nose.plugins.builtin`.
    cCsKddlm}x!|jD]}|j|��qWtt|�j�dS(s-Load plugins in nose.plugins.builtin
        i�(tbuiltinN(tnose.pluginsR�RRR�R	RO(RR�RJ((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRO�s(RR?R@RO(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR	�scBseZRS((RR?(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�scBseZRS((RR?(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�scBs2eZdZdded�Zd�Zd�ZRS(s�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.
    cCs8tj||�||_||_g|_d|_dS(N(RRR�texcludetexcludedR!t
_excludedOpts(RRR�R�((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR�s
			cCsr|jdkr^ddlm}|dt�|_x*|jD]}|j|jdi�q;Wn|jjd|�S(Ni�(tOptionParsertadd_help_optionRjs--(R�R!toptparseR�R.R�RLt
get_option(RRWR�R&((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pytexcludedOption�scCs�|jrtj|�ng}xj|jD]_}t}x:|jD]/}t||�r?t}|jj	|�Pq?q?W|r)|j	|�q)q)W||_dS(N(
R�RRORRcR�RpR.R�R%(RtallowR&tokR((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyRO�s	(((RR?R@RcRR�RO(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyR
�s	((%R@R#tloggingR�R7t	itertoolsRRZtwarningsRtnose.configtnosetnose.failureRtnose.plugins.baseRtnose.pyversionRtcPickletpicklet	cStringIORt__all__t	getLoggerRR\RXRRARRgRR	R�RtImportErrorR
(((s8/sys/lib/python2.7/site-packages/nose/plugins/manager.pyt<module>2sB	m&T;%


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.