%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/manager.cpython-37.pyc

B

9�`�<�@s�dZddlZddlZddlZddlZddlmZddlm	Z	ddl
Zddlm
Z
ddlmZddlmZyddlZWnddlZYnXyddlmZWnddlmZYnXd	d
ddd
gZe�e�ZGdd�de�ZGdd�de�ZGdd
�d
e�ZGdd�d�ZGdd�de�ZGdd�de�Zyddl Z Gdd	�d	ee�Z!Wn&e"k
�rnGdd	�d	e�Z!YnXGdd
�d
e!�Z#dS)a
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``.

�N)�chain)�warn)�Failure)�IPluginInterface)�	sort_list)�StringIO�DefaultPluginManager�
PluginManager�EntryPointPluginManager�BuiltinPluginManager�RestrictedPluginManagerc@sVeZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zddd�Z
dS)�PluginProxya#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.
    cCslyt|j|�|_Wn(tk
r:td||jjf��YnX|�|�|_g|_x|D]}|�||�qTWdS)Nz%s is not a valid %s method)	�getattr�	interface�method�AttributeError�__name__�makeCall�call�plugins�	addPlugin)�selfrr�p�r�E/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/manager.py�__init__Ws
zPluginProxy.__init__cOs|j||�S)N)r)r�arg�kwrrr�__call__bszPluginProxy.__call__csVt||d�}|dk	rR|dkrBtt�|�d�dkrB|��fdd�}|j�||f�dS)z`Add plugin to my list of plugins to call, if it has the attribute
        I'm bound to.
        NZloadTestsFromModuler�cs�|�S)Nr)�module�path�kwargs)�	orig_methrr�<lambda>n�z'PluginProxy.addPlugin.<locals>.<lambda>)r�len�inspectZ
getargspecr�append)r�pluginr�methr)r#rreszPluginProxy.addPlugincsH|dkr�jS�j}t|dd�r,�fdd�St|dd�r>�jS�jSdS)NZloadTestsFromNames�
generativeFcst�j||��S)N)�list�generate)rr)rrrr${r%z&PluginProxy.makeCall.<locals>.<lambda>Z	chainable)�_loadTestsFromNamesrrr�simple)rrr*r)rrrqszPluginProxy.makeCallcOsZd}dd�tt|jdg�|�D�}x2|jD](\}}|||�}|dd�}|�|�q*W|S)z�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.
        NcSsg|]\}}|r|�qSrr)�.0�static�arrr�
<listcomp>�sz%PluginProxy.chain.<locals>.<listcomp>Zstatic_args)�ziprrrr()rrr�resultr1rr*rrrr�s
zPluginProxy.chainc
os�xz|jD]p\}}d}y*|||�}|dk	r<x|D]
}|Vq.WWqttfk
rX�Yqt��}t|�VwYqXqWdS)zFCall all plugins, yielding each item in each non-None result.
        N)r�KeyboardInterrupt�
SystemExit�sys�exc_infor)rrrrr*r5�r�excrrrr-�s


zPluginProxy.generatecOs.x(|jD]\}}|||�}|dk	r|SqWdS)z?Call all plugins, returning the first non-None result.
        N)r)rrrrr*r5rrrr/�s
zPluginProxy.simpleNcCsJg}x<|jD]2\}}|||d�}|dk	r|\}}|r|�|�qW||fS)a
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.
        )r N)r�extend)r�namesr Zsuiterr*r5Z
suite_partrrrr.�szPluginProxy._loadTestsFromNames)N)r�
__module__�__qualname__�__doc__rrrrrrrr-r/r.rrrrr
Nsr
c@sdeZdZdZeZdd�Zdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�Zdd�ZdS)�	NoPluginsz(Null Plugin manager that has no plugins.cCsd|_|_dS)Nr)�_pluginsr)rrrrr�szNoPlugins.__init__cCsdS)Nrr)rrrr�__iter__�szNoPlugins.__iter__cOsdS)Nr)r�args�kwdsrrr�
_doNothing�szNoPlugins._doNothingcOsdS)Nrr)rrDrErrr�_emptyIterator�szNoPlugins._emptyIteratorcCs(t|j|�}t|dd�r|jS|jSdS)Nr+F)rrrGrF)rrrrrr�__getattr__�szNoPlugins.__getattr__cCs
t��dS)N)�NotImplementedError)r�plugrrrr�szNoPlugins.addPlugincCs
t��dS)N)rI)rrrrr�
addPlugins�szNoPlugins.addPluginscCsdS)Nr)r�options�configrrr�	configure�szNoPlugins.configurecCsdS)Nr)rrrr�loadPlugins�szNoPlugins.loadPluginscCsdS)Nr)rrrr�sort�szNoPlugins.sortN)rr>r?r@rrrrCrFrGrHrrKrNrOrPrrrrrA�srAc@sveZdZdZeZddd�Zdd�Zdd	�Zd
d�Z	ddd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zeeedd�ZdS)r	a�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.
    rNcCs2g|_d|_i|_|r |�|�|dk	r.||_dS)Nr)rB�
_extraplugins�_proxiesrK�
proxyClass)rrrSrrrr�s
zPluginManager.__init__cCs<y
|j|Stk
r6|�||j�}||j|<YnX|S)N)rR�KeyErrorrSrB)rr�proxyrrrrH�s
zPluginManager.__getattr__cCs
t|j�S)N)�iterr)rrrrrCszPluginManager.__iter__cs<t|dt����fdd�|jD�|jdd�<|j�|�dS)N�namecs g|]}t|dd��kr|�qS)rWN)r)r0r)�new_namerrr3sz+PluginManager.addPlugin.<locals>.<listcomp>)r�objectrBr()rrJr)rXrrszPluginManager.addPlugincCs(||_xt||�D]}|�|�qWdS)z�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)rQ�	iterchainr)rrZextrapluginsrJrrrrKszPluginManager.addPluginscCsTt�d�||_td|j�}|||�dd�|jD�}||_|��t�d|�dS)z�Configure the set of plugins with the given options
        and config instance. After configuration, disabled plugins
        are removed from the plugins list.
        zConfiguring pluginsrNcSsg|]}|jr|�qSr)�enabled)r0rJrrrr3sz+PluginManager.configure.<locals>.<listcomp>zPlugins enabled: %sN)�log�debugrMr
rBrrP)rrLrMZcfgr[rrrrNs

zPluginManager.configurecCsx|jD]}|�|�qWdS)N)rQr)rrJrrrrO"szPluginManager.loadPluginscCst|jdd�dd�S)NcSst|dd�S)NZscore�)r)�xrrrr$'r%z$PluginManager.sort.<locals>.<lambda>T)�reverse)rrB)rrrrrP&szPluginManager.sortcCs|jS)N)rB)rrrr�_get_plugins)szPluginManager._get_pluginscCsg|_|�|�dS)N)rBrK)rrrrr�_set_plugins,szPluginManager._set_pluginszPAccess the list of plugins managed by
                       this plugin manager)rN)rr)rr>r?r@r
rSrrHrCrrKrNrOrPrarb�propertyrrrrrr	�s
	
	c@s^eZdZdZdd�Zejfdd�Zdd�Zdd	�Z	d
d�Z
dd
�Zdd�Zdd�Z
dd�ZdS)�ZeroNinePluginz>Proxy for 0.9 plugins, adapts 0.10 calls to 0.9 standard.
    cCs
||_dS)N)r))rr)rrrr8szZeroNinePlugin.__init__cCs|j�||�dS)N)r)Zadd_options)r�parser�envrrrrL;szZeroNinePlugin.optionsc	Cs�t|jd�sdSddlm}m}|\}}}t||�rRt|jd�sDdS|j�|j�St||�rzt|jd�sldS|j�|j�S|j	}|j�
|j||�S)N�addErrorr)�SkipTest�DeprecatedTest�addSkip�
addDeprecated)�hasattrr)Znose.excrhri�
issubclassrj�testrk�capturedOutputrg)	rrn�errrhriZecZev�tb�captrrrrg>s


zZeroNinePlugin.addErrorcCst|jd�r|j�|�SdS)N�loadTestsFromPath)rlr)rs)r�filenamerrr�loadTestsFromFilePsz ZeroNinePlugin.loadTestsFromFilecCs0t|jd�sdS|j}|j}|j�|j|||�S)N�
addFailure)rlr)ro�tbinforvrn)rrnrprrrwrrrrvTs
zZeroNinePlugin.addFailurecCs*t|jd�sdS|j}|j�|j|�dS)N�
addSuccess)rlr)rorxrn)rrnrrrrrrx\szZeroNinePlugin.addSuccesscCst|jd�sdS|j�|j�S)N�	startTest)rlr)ryrn)rrnrrrrybszZeroNinePlugin.startTestcCst|jd�sdS|j�|j�S)N�stopTest)rlr)rzrn)rrnrrrrzgszZeroNinePlugin.stopTestcCst|j|�S)N)rr))r�valrrrrHlszZeroNinePlugin.__getattr__N)rr>r?r@r�os�environrLrgrurvrxryrzrHrrrrrd5srdcs,eZdZdZddeffZ�fdd�Z�ZS)r
zhPlugin manager that loads plugins from the `nose.plugins` and
    `nose.plugins.0.10` entry points.
    )znose.plugins.0.10Nznose.pluginsc	s�ddlm}i}x�|jD]�\}}x�||�D]�}|j|kr:q*d||j<t�d|jj|�y|��}WnJt	k
rx�Yn6t
k
r�}ztd||ft�w*Wdd}~XYnX|r�||��}n|�}|�
|�q*WqWtt|���dS)zBLoad plugins by iterating the `nose.plugins` entry point.
        r)�iter_entry_pointsTz%s load plugin %szUnable to load plugin %s: %sN)�
pkg_resourcesr~�entry_pointsrWr\r]�	__class__r�loadr6�	Exceptionr�RuntimeWarningr�superr
rO)	rr~ZloadedZentry_pointZadaptZepZplugcls�erJ)r�rrrOws*

z#EntryPointPluginManager.loadPlugins)rr>r?r@rdr�rO�
__classcell__rr)r�rr
ps
cs eZdZdZ�fdd�Z�ZS)rzSPlugin manager that loads plugins from the list in
    `nose.plugins.builtin`.
    cs:ddlm}x|jD]}|�|��qWtt|���dS)z-Load plugins in nose.plugins.builtin
        r)�builtinN)Znose.pluginsr�rrr�rrO)rr�rJ)r�rrrO�sz BuiltinPluginManager.loadPlugins)rr>r?r@rOr�rr)r�rr�sc@seZdZdS)rN)rr>r?rrrrr�sc@seZdZdS)rN)rr>r?rrrrr�sc@s*eZdZdZddd�Zdd�Zdd	�Zd
S)rz�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.
    rTcCs(t�||�||_||_g|_d|_dS)N)rrr��exclude�excluded�
_excludedOpts)rrr�r�rrrr�s
z RestrictedPluginManager.__init__cCsR|jdkrBddlm}|dd�|_x|jD]}|j|jid�q*W|j�d|�S)Nr)�OptionParserF)Zadd_help_option)rfz--)r�Zoptparser�r�rLZ
get_option)rrWr�r)rrr�excludedOption�s
z&RestrictedPluginManager.excludedOptioncCsl|jrt�|�g}xL|jD]B}d}x*|jD] }t||�r,d}|j�|�Pq,W|r|�|�qW||_dS)NTF)r�rrOrr�rlr�r()rZallowr)�okrrrrrO�s

z#RestrictedPluginManager.loadPluginsN)rrT)rr>r?r@rr�rOrrrrr�s
)$r@r'Zloggingr|r8�	itertoolsrrZ�warningsrZnose.configZnoseZnose.failurerZnose.plugins.baserZnose.pyversionr�pickle�ior�__all__Z	getLoggerrr\rYr
rAr	rdr
rrr�ImportErrorrrrrr�<module>2sB
m&T;%

Zerion Mini Shell 1.0