Your IP : 216.73.216.61


Current Path : /opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/suite.cpython-35.pyc



�^�]*W�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZmZm
Z
ejdkr�ejdd�dd	fkr�ddlZejd
�ddlmZnGdd
�d
e�Zeje�Ze�Zdd�ZGdd�de�ZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�Z Gdd�dej�Z!Gdd�d�Z"Gdd�d�Z#dS) z�
Test Suites
-----------

Provides a LazySuite, which is a suite whose test list is a generator
function, and ContextSuite,which can run fixtures (setup/teardown
functions or methods) for the context that contains its tests.

�N)�Test)�Config)�ResultProxyFactory)�isclass�resolve_name�try_run�cli���
IronPython)�StringExceptionc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�;/opt/alt/python35/lib/python3.5/site-packages/nose/suite.pyrsrcCsd|j|jfS)Nz%s.%s)rr
)�clsrrr�	_strclass$src@seZdZdZdS)�MixedContextErrorzQError raised when a context suite sees tests from more than
    one context.
    N)r
rr�__doc__rrrrr'srcs�eZdZdZf�fdd�Zdd�Zdd�Zdd	�ZeZd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
eee
dd�Z�S)�	LazySuitez:A suite that may use a generator as its list of tests
    cs$tt|�j�|j|�dS)zFInitialize the suite. tests may be an iterable or a generator
        N)�superr�__init__�
_set_tests)�self�tests)�	__class__rrr1szLazySuite.__init__cCs
t|j�S)N)�iter�_tests)rrrr�__iter__7szLazySuite.__iter__cCsdt|j�t|�fS)Nz<%s tests=generator (%s)>)rr�id)rrrr�__repr__:szLazySuite.__repr__cCs
tj|�S)N)�object�__hash__)rrrrr#>szLazySuite.__hash__cCs|jj|�dS)N)�	_precache�append)r�testrrr�addTestCszLazySuite.addTestcCs,x%|jD]}|jrP||�q
W|S)N)r�
shouldStop)r�resultr&rrr�runGs
	z
LazySuite.runcCs�tjdt|��|jr#dS|jdkr6dSy3t|j�}|dk	rh|jj|�dSWntk
r}YnXdS)Nztests in %s?TF)�log�debugr r$�test_generator�nextr%�
StopIteration)rr&rrr�__bool__Ns	
zLazySuite.__bool__ccs\tjd|j�x|jD]}|VqW|jdkr?dSx|jD]}|VqIWdS)Nzprecache is %s)r+r,r$r-)rr&rrr�
_get_tests]s	zLazySuite._get_testscCsyg|_t|tj�}t|�r=|r=|�|_n8|r_|j|g�d|_n|j|�d|_dS)N)r$�
isinstance�unittest�	TestSuite�callabler-�addTests)rrZis_suiterrrrfs	
zLazySuite._set_testsNzbAccess the tests in this suite. Access is through a generator, so iteration may not be repeatable.)r
rrrrrr!r#�__str__r'r*r0r1r�propertyrrr)rrr.s	rc	sKeZdZdZejjZdZdZdBZ	dCZ
dDZdEZdFZ
dGZfddddd �fd!d"�Zd#d$�ZeZd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zdd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Zd=d>�Zd?d@�Ze ee!j"ddA�Z#�S)H�ContextSuitea4A suite with context.

    A ContextSuite executes fixtures (setup and teardown functions or
    methods) for the context containing its tests.

    The context may be explicitly passed. If it is not, a context (or
    nested set of contexts) will be constructed by examining the tests
    in the suite.
    F�setup_class�	setup_all�
setupClass�setupAll�
setUpClass�setUpAll�teardown_class�teardown_all�
teardownClass�teardownAll�
tearDownClass�tearDownAll�setup_module�setupModule�setUpModule�setup�setUp�teardown_module�teardownModule�tearDownModule�teardown�tearDown�
setup_package�setupPackage�setUpPackage�teardown_package�teardownPackage�tearDownPackageNTcs�tjd||t|��||_||_|dkrCt�}||_||_d|_||_	d|_
tt|�j
|�dS)NzContext suite for %s (%s) (%s)F)r+r,r �context�factoryr�config�resultProxy�has_run�	can_split�
error_contextrr9r)rrrVrWrXrYr[)rrrr�s								zContextSuite.__init__cCs)dt|j�t|jd|j�fS)Nz<%s context=%s>r
)rr�getattrrV)rrrrr!�szContextSuite.__repr__cCs.|jr dt|�|jfSt|�SdS)Nz%s:%s)r\�repr)rrrrr �s	zContextSuite.idcCs
tj|�S)N)r"r#)rrrrr#�szContextSuite.__hash__cOs|j||�S)N)r*)r�arg�kwrrr�__call__�szContextSuite.__call__cCs
tj�S)z.Hook for replacing error tuple output
        )�sys�exc_info)rrrrrc�szContextSuite.exc_infocCsS|j�}tjdkrOt|dt�rOt|d�|d|df}|S)z:Bottleneck to fix up IronPython string exceptions
        rr�r	)rcrb�platformr2r�str)r�errr�	_exc_info�s
!zContextSuite._exc_infocCs7tjdt|�||j�|jrD|j||�|}}n
||}}y|j�Wn?tk
rv�Yn+d|_|j||j	��dSYnXz9x2|jD]'}|j
r�tjd�P||�q�WWdd|_y|j�Wn;tk
r�Yn'd|_|j||j	��YnXXdS)z5Run tests in suite inside of suite fixtures.
        z#suite %s (%s) run called, tests: %srINZstoppingTrN)
r+r,r rrYrJ�KeyboardInterruptr\�addErrorrhr(rZrO)rr)�origr&rrrr*�s4	

			
	
	zContextSuite.runcCs�|j}|dkrdS|j|d|�r2dS|j}|r�|jj|g�}x'|D]}|j|d|�r]dSq]WdS)NF�ctx_callbackT)rV�implementsAnyFixturerW�get)rrlrVrW�	ancestors�ancestorrrr�hasFixtures�s		
zContextSuite.hasFixturescCs�t|�r|j|j}n3|j|j}t|d�rR||j|j7}d}x$|D]}t||�r_d}Pq_W|dkr�|S|||�S)N�__path__FT)r�
classSetup�
classTeardown�moduleSetup�moduleTeardown�hasattr�packageSetup�packageTeardown)rrVrl�namesZfixt�mrrrrm�s
z!ContextSuite.implementsAnyFixturecCsDtjdt|�|j�|s<tjdt|��dS|jr_tjdt|��dS|j}|dkrxdS|j}|r|jj|g�dd�}xU|r�|j�}tjd|�||jkr�q�tjd|�|j	|�q�W||jkr*|j	|�n
|j	|�d|_tjd�dS)Nz suite %s setUp called, tests: %szsuite %s has no testszsuite %s already set upzancestor %s may need setupzancestor %s does need setupTzcompleted suite setup)
r+r,r r�	was_setuprVrWrn�pop�setupContext)rrVrWrorprrrrJs2				
	zContextSuite.setUpcCs�|jjj|�tjd||�|jrU||jjkrEdS||jj|<t|�rm|j}n%|j	}t
|d�r�|j|}t||�dS)Nz%s setup context %srr)
rX�pluginsZstartContextr+r,rWr|rrsrurwrxr)rrVrzrrrr~,s		
zContextSuite.setupContextcCs|jdkrdSd|jS)Nz
test suiteztest suite for %s)rV)rrrr�shortDescription=szContextSuite.shortDescriptioncCsMtjd�|js |jrAtjd|j|jf�dSd|_|j}|dkrptjd�dS|j}|r<|jj|g�|g}x�|D]�}tjd|�||jkr�tjd|�q�||jkr�tjd|�q�|j|}tjd||�||kr�|j|�q�Wn
|j|�dS)	Nzcontext teardownz6No reason to teardown (was_setup? %s was_torndown? %s)TzNo context to tear downzancestor %s may need teardownzancestor %s was not setupzancestor %s already torn downz%s setup ancestor %s)r+r,r|�was_torndownrVrWrn�teardownContext)rrVrWrorprIrrrrOBs6
		
	

zContextSuite.tearDowncCs�tjd||�|jrB||jjkr2dS||jj|<t|�rZ|j}n%|j}t|d�r|j|}t	||�|j
jj|�dS)Nz%s teardown context %srr)
r+r,rWr�rrtrvrwryrrXrZstopContext)rrVrzrrrr�cs		

zContextSuite.teardownContextccsaxZ|j�D]L}t|t�s4t|tj�r<|Vq
t|d|jd|j�Vq
WdS)NrXrY)r1r2rr3r4rXrY)rr&rrr�_get_wrapped_testsss!		zContextSuite._get_wrapped_testszOAccess the tests in this suite. Tests are returned inside of a context wrapper.)r:r;r<r=r>r?)r@rArBrCrDrE)rFrGrHrIrJ)rKrLrMrNrO)rPrQrR)rSrTrU)$r
rrrr3�TestCase�failureExceptionr|r�rsrtrurvrxryrr!r7r r#rarcrhr*rqrmrJr~r�rOr�r�r8rrrrr)rrr9ysF		

& !	r9c@syeZdZdZeZddedd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dS)�ContextSuiteFactoryaCFactory for ContextSuites. Called with a collection of tests,
    the factory decides on a hierarchy of contexts by introspecting
    the collection or the tests themselves to find the objects
    containing the test objects. It always returns one suite, but that
    suite may consist of a hierarchy of nested suites.
    NcCs|dkrt�}||_|dk	r3||_|tkrNtd|�}||_i|_i|_i|_i|_	dS)NrX)
rrX�
suiteClass�_defrrY�suitesrVr|r�)rrXr�rYrrrr�s							zContextSuiteFactory.__init__cKs�tjd|�|jdt|dd��}tjd||�|dkr�|j|�}y|j|�}Wn.tk
r�|j|j|�d|�SYnX|j|||�S)a�Return ``ContextSuite`` for tests. ``tests`` may either
        be a callable (in which case the resulting ContextSuite will
        have no parent context and be evaluated lazily) or an
        iterable. In that case the tests will wrapped in
        nose.case.Test, be examined and the context of each found and a
        suite of suites returned, organized into a stack with the
        outermost suites belonging to the outermost contexts.
        zCreate suite for %srVNztests %s context %s)	r+r,r}r]�	wrapTests�findContextr�	makeSuite�mixedSuites)rrr`rVrrrra�s	
!zContextSuiteFactory.__call__ccs�tjd|�|dkr dSt|d�r>|jj}nt|d�rY|jj}t|d�r}|jjd�}n>t|d�r�|jjd�dd�}ntd	|��x;|r�tjd
||�t	dj
|��V|j�q�WdS)z�Return the ancestry of the context (that is, all of the
        packages and modules containing the context), in order of
        descent with the outermost ancestor last.
        This method is a generator.
        zget ancestry %sNZim_class�__self__r�.r
rdz%s has no ancestors?z %s ancestors %s���)r+r,rwr�rr�splitr
�	TypeErrorr�joinr})rrVrorrr�ancestry�s 	zContextSuiteFactory.ancestrycCs�t|�st|tj�r"dSd}xf|D]^}t|dd�}|dkrVq/|dkrk|}q/||kr/td||f��q/W|S)NrVz5Tests with different contexts in same suite! %s != %s)r5r2r3r4r]r)rrrVr&�ctxrrrr��s
	zContextSuiteFactory.findContextcKs�|j|d|d|jd|d|j|�}|dk	r�|jj|g�j|�|jj|g�j|�tjd|t	|dd��x]|j
|�D]L}|jj|g�j|�|j|j|�tjd||j�q�W|S)NrVrXrWrYzsuite %s has context %sr
zsuite %s has ancestor %s)r�rXrYr��
setdefaultr%rVr+r,r]r�r
)rrrVr`�suiterprrrr��szContextSuiteFactory.makeSuitecCs}|s
gS|jd�}|s&|gS|}|dd�}t|dd�}|dk	rr|gdd�|j|�D�}x�|D]�}|g}g}	x�|D]�}
d}t|
dd�}|dkr�|	j|
�q�||kr�|j|
�q�x7|j|�D]&}
|
|kr|j|
�d}PqW|s�|	j|
�q�W|r_|j||�}|j|	�}q�W|g|S)acThe complex case where there are tests that don't all share
        the same context. Groups tests into suites with common ancestors,
        according to the following (essentially tail-recursive) procedure:

        Starting with the context of the first test, if it is not
        None, look for tests in the remaining tests that share that
        ancestor. If any are found, group into a suite with that
        ancestor as the context, and replace the current suite with
        that suite. Continue this process for each ancestor of the
        first test, until all ancestors have been processed. At this
        point if any tests remain, recurse with those tests as the
        input, returning a list of the common suite (which may be the
        suite or test we started with, if no common tests were found)
        plus the results of recursion.
        rNrVcSsg|]}|�qSrr)�.0�arrr�
<listcomp>s	z3ContextSuiteFactory.mixedSuites.<locals>.<listcomp>FT)r}r]r�r%r�r�)rr�headr��tailrVrorp�commonZremainr&Zfound_commonZtest_ctxZ
test_ancestorrrrr��sB#
	



zContextSuiteFactory.mixedSuitescCs�tjd|�t|�s.t|tj�r?tjd�|Sg}x�|D]�}tjd|�t|t�s�t|tj�r�|j|�qLt|t�r�|j|j	|d|j
��qL|jt|d|jd|j��qLW|S)Nzwrap %szI won't wrapzwrapping %srVrXrY)
r+r,r5r2r3r4rr%�ContextListr�rVrXrY)rr�wrappedr&rrrr�s

!"#zContextSuiteFactory.wrapTests)r
rrrr9r�r�rrar�r�r�r�r�rrrrr��s2r�c@s1eZdZdZddd�Zdd�ZdS)r�z�Not quite a suite -- a group of tests in a context. This is used
    to hint the ContextSuiteFactory about what context the tests
    belong to, in cases where it may be ambiguous or missing.
    NcCs||_||_dS)N)rrV)rrrVrrrr2s	zContextList.__init__cCs
t|j�S)N)rr)rrrrr6szContextList.__iter__)r
rrrrrrrrrr�-sr�csLeZdZdZ�fdd�Zdd�Zdd�Zdd	�Z�S)
�FinalizingSuiteWrapperz�Wraps suite and calls final function after suite has
    executed. Used to call final functions in cases (like running in
    the standard test runner) where test running is not under nose's
    control.
    cs)tt|�j�||_||_dS)N)rr�rr��finalize)rr�r�)rrrr@s	zFinalizingSuiteWrapper.__init__cOs|j||�S)N)r*)rr_r`rrrraEszFinalizingSuiteWrapper.__call__cCs
t|j�S)N)rr�)rrrrrIszFinalizingSuiteWrapper.__iter__cOs,z|j||�SWd|j||�XdS)N)r�r�)rr_r`rrrr*LszFinalizingSuiteWrapper.run)r
rrrrrarr*rr)rrr�:s
r�c@seZdZdd�ZdS)�TestDircOstd��dS)Nz�TestDir is not usable with nose 0.10. The class is present in nose.suite for backwards compatibility purposes but it may not be used.)�NotImplementedError)r_r`rrrrUszTestDir.__init__N)r
rrrrrrrr�Tsr�c@seZdZdd�ZdS)�
TestModulecOstd��dS)Nz�TestModule is not usable with nose 0.10. The class is present in nose.suite for backwards compatibility purposes but it may not be used.)r�)r_r`rrrr]szTestModule.__init__N)r
rrrrrrrr�\sr�)$r�loggingrbr3Z	nose.caserZnose.configrZ
nose.proxyrZ	nose.utilrrrre�version_infoZclrZAddReferenceZIronPython.Runtime.Exceptionsr�	Exception�	getLoggerr
r+r"r�rrr4rr9r�r�r�r�r�rrrr�<module>	s2
	K�	�