Current File : //lib/python2.7/site-packages/nose/suite.pyc
�
d�Uc@s�dZddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddlm
Z
mZmZejdkr�ejd	 d	d
fkr�ddlZejd�ddlmZnd
efd��YZneje�Ze�Zd�Zdefd��YZdejfd��YZdefd��YZ defd��YZ!defd��YZ"dejfd��YZ#dfd��YZ$dfd��YZ%dS( s�
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.

i����(t
generatorsN(tTest(tConfig(tResultProxyFactory(tisclasstresolve_namettry_runtcliiit
IronPython(tStringExceptionR	cBseZRS((t__name__t
__module__(((s./usr/lib/python2.7/site-packages/nose/suite.pyR	scCsd|j|jfS(Ns%s.%s(RR
(tcls((s./usr/lib/python2.7/site-packages/nose/suite.pyt	_strclass$stMixedContextErrorcBseZdZRS(sQError raised when a context suite sees tests from more than
    one context.
    (R
Rt__doc__(((s./usr/lib/python2.7/site-packages/nose/suite.pyR'st	LazySuitecBs}eZdZdd�Zd�Zd�Zd�ZeZd�Zd�Z	d�Z
d�Zd	�Ze
eedd
�ZRS(
s:A suite that may use a generator as its list of tests
    cCs$tt|�j�|j|�dS(sFInitialize the suite. tests may be an iterable or a generator
        N(tsuperRt__init__t
_set_tests(tselfttests((s./usr/lib/python2.7/site-packages/nose/suite.pyR1scCs
t|j�S(N(titert_tests(R((s./usr/lib/python2.7/site-packages/nose/suite.pyt__iter__7scCsdt|j�t|�fS(Ns<%s tests=generator (%s)>(R
t	__class__tid(R((s./usr/lib/python2.7/site-packages/nose/suite.pyt__repr__:scCs
tj|�S(N(tobjectt__hash__(R((s./usr/lib/python2.7/site-packages/nose/suite.pyR>scCs|jj|�dS(N(t	_precachetappend(Rttest((s./usr/lib/python2.7/site-packages/nose/suite.pytaddTestCscCs/x(|jD]}|jrPn||�q
W|S(N(Rt
shouldStop(RtresultR ((s./usr/lib/python2.7/site-packages/nose/suite.pytrunGs
	cCs�tjdt|��|jr#tS|jdkr6tSy3|jj�}|dk	rh|jj	|�tSWnt
k
r|nXtS(Nstests in %s?(tlogtdebugRRtTruettest_generatortNonetFalsetnextRt
StopIteration(RR ((s./usr/lib/python2.7/site-packages/nose/suite.pyt__nonzero__Ns	
ccs\tjd|j�x|jD]}|VqW|jdkr?dSx|jD]}|VqIWdS(Nsprecache is %s(R%R&RR(R)(RR ((s./usr/lib/python2.7/site-packages/nose/suite.pyt
_get_tests]s	cCsyg|_t|tj�}t|�r=|r=|�|_n8|r_|j|g�d|_n|j|�d|_dS(N(Rt
isinstancetunittestt	TestSuitetcallableR(taddTestsR)(RRtis_suite((s./usr/lib/python2.7/site-packages/nose/suite.pyRfs	
sbAccess the tests in this suite. Access is through a generator, so iteration may not be repeatable.(N(R
RRRRRRt__str__R!R$R-R.RtpropertyR)R(((s./usr/lib/python2.7/site-packages/nose/suite.pyR.s									tContextSuitecBs
eZdZejjZeZeZd.Z	d/Z
d0Zd1Zd2Z
d3Zd4d5d5d5d5ed�Zd�ZeZd�Zd �Zd!�Zd"�Zd#�Zd$�Zd5d%�Zd&�Zd'�Zd(�Zd)�Zd*�Zd+�Z d,�Z!e"e!e#j$d5d-�Z%RS(6s4A 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.
    tsetup_classt	setup_allt
setupClasstsetupAllt
setUpClasstsetUpAlltteardown_classtteardown_allt
teardownClasstteardownAllt
tearDownClassttearDownAlltsetup_moduletsetupModuletsetUpModuletsetuptsetUptteardown_moduletteardownModulettearDownModuletteardownttearDownt
setup_packagetsetupPackagetsetUpPackagetteardown_packagetteardownPackagettearDownPackagecCs�tjd||t|��||_||_|dkrFt�}n||_||_t	|_
||_d|_t
t|�j|�dS(NsContext suite for %s (%s) (%s)(R%R&RtcontexttfactoryR)RtconfigtresultProxyR*thas_runt	can_splitt
error_contextRR7R(RRRTRURVRWRY((s./usr/lib/python2.7/site-packages/nose/suite.pyR�s							cCs)dt|j�t|jd|j�fS(Ns<%s context=%s>R
(R
RtgetattrRT(R((s./usr/lib/python2.7/site-packages/nose/suite.pyR�scCs.|jr dt|�|jfSt|�SdS(Ns%s:%s(RZtrepr(R((s./usr/lib/python2.7/site-packages/nose/suite.pyR�s	cCs
tj|�S(N(RR(R((s./usr/lib/python2.7/site-packages/nose/suite.pyR�scOs|j||�S(N(R$(Rtargtkw((s./usr/lib/python2.7/site-packages/nose/suite.pyt__call__�scCs
tj�S(s.Hook for replacing error tuple output
        (tsystexc_info(R((s./usr/lib/python2.7/site-packages/nose/suite.pyRa�scCsY|j�}tjdkrUt|dt�rUt|d�|d|df}qUn|S(s:Bottleneck to fix up IronPython string exceptions
        Riii(RaR`tplatformR/R	tstr(Rte((s./usr/lib/python2.7/site-packages/nose/suite.pyt	_exc_info�s
'cCs3tjdt|�||j�|jrD|j||�|}}n
||}}y|j�Wn:tk
ru�n'd|_|j||j	��dSXz<x5|jD]*}|j
r�tjd�Pn||�q�WWdt|_y|j
�Wn9tk
r�n&d|_|j||j	��nXXdS(s5Run tests in suite inside of suite fixtures.
        s#suite %s (%s) run called, tests: %sRGNtstoppingRL(R%R&RRRWRHtKeyboardInterruptRZtaddErrorReR"R'RXRM(RR#torigR ((s./usr/lib/python2.7/site-packages/nose/suite.pyR$�s4	

		
	
	cCs�|j}|dkrtS|j|d|�r2tS|j}|r�|jj|g�}x*|D]}|j|d|�r]tSq]WntS(Ntctx_callback(RTR)R*timplementsAnyFixtureR'RUtget(RRjRTRUt	ancestorstancestor((s./usr/lib/python2.7/site-packages/nose/suite.pythasFixtures�s		
cCs�t|�r|j|j}n6|j|j}t|d�rU||j|j7}nt}x'|D]}t||�rbt	}PqbqbW|dkr�|S|||�S(Nt__path__(Rt
classSetupt
classTeardowntmoduleSetuptmoduleTeardownthasattrtpackageSetuptpackageTeardownR*R'R)(RRTRjtnamestfixttm((s./usr/lib/python2.7/site-packages/nose/suite.pyRk�s
cCsAtjdt|�|j�|s<tjdt|��dS|jr_tjdt|��dS|j}|dkrxdS|j}|r|jj|g�}xX|r�|j	�}tjd|�||jkr�q�ntjd|�|j
|�q�W||jkr'|j
|�q'n
|j
|�t|_tjd�dS(Ns suite %s setUp called, tests: %sssuite %s has no testsssuite %s already set upsancestor %s may need setupsancestor %s does need setupscompleted suite setup(R%R&RRt	was_setupRTR)RURltpoptsetupContextR'(RRTRURmRn((s./usr/lib/python2.7/site-packages/nose/suite.pyRHs2				
	cCs�|jjj|�tjd||�|jrX||jjkrEdS||jj|<nt|�rp|j}n(|j	}t
|d�r�|j|}nt||�dS(Ns%s setup context %sRp(
RVtpluginststartContextR%R&RUR{RRqRsRuRvR(RRTRx((s./usr/lib/python2.7/site-packages/nose/suite.pyR},s		cCs|jdkrdSd|jS(Ns
test suitestest suite for %s(RTR)(R((s./usr/lib/python2.7/site-packages/nose/suite.pytshortDescription=scCsVtjd�|js |jrAtjd|j|jf�dSt|_|j}|dkrptjd�dS|j}|rE|jj|g�|g}x�|D]�}tjd|�||jkr�tjd|�q�n||jkrtjd|�q�n|j|}tjd||�||kr�|j	|�q�q�Wn
|j	|�dS(Nscontext teardowns6No reason to teardown (was_setup? %s was_torndown? %s)sNo context to tear downsancestor %s may need teardownsancestor %s was not setupsancestor %s already torn downs%s setup ancestor %s(
R%R&R{twas_torndownR'RTR)RURltteardownContext(RRTRURmRnRG((s./usr/lib/python2.7/site-packages/nose/suite.pyRMBs6
		
	

cCs�tjd||�|jrE||jjkr2dS||jj|<nt|�r]|j}n(|j}t|d�r�|j|}nt	||�|j
jj|�dS(Ns%s teardown context %sRp(
R%R&RUR�RRrRtRuRwRRVR~tstopContext(RRTRx((s./usr/lib/python2.7/site-packages/nose/suite.pyR�cs		
ccsaxZ|j�D]L}t|t�s4t|tj�r<|Vq
t|d|jd|j�Vq
WdS(NRVRW(R.R/RR0R1RVRW(RR ((s./usr/lib/python2.7/site-packages/nose/suite.pyt_get_wrapped_testsss!		sOAccess the tests in this suite. Tests are returned inside of a context wrapper.(R8R9R:R;R<R=(R>R?R@RARBRC(RDRERFssetupssetUp(RIRJRKsteardownstearDown(RNRORP(RQRRRS(N(&R
RRR0tTestCasetfailureExceptionR*R{R�RqRrRsRtRvRwR)R'RRR5RRR_RaReR$RoRkRHR}R�RMR�R�R6RRR(((s./usr/lib/python2.7/site-packages/nose/suite.pyR7ysF		
						
	&		 			!			tContextSuiteFactorycBs\eZdZeZdded�Zd�Zd�Z	d�Z
d�Zd�Zd�Z
RS(	sCFactory 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.
    cCs�|dkrt�}n||_|dk	r9||_n|tkrWtd|�}n||_i|_i|_i|_	i|_
dS(NRV(R)RRVt
suiteClasst_defRRWtsuitesRTR{R�(RRVR�RW((s./usr/lib/python2.7/site-packages/nose/suite.pyR�s					cKs�tjd|�|jdt|dd��}tjd||�|dkr�|j|�}y|j|�}Wq�tk
r�|j|j	|�d|�SXn|j|||�S(s�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.
        sCreate suite for %sRTstests %s context %sN(
R%R&R|R[R)t	wrapTeststfindContextRt	makeSuitetmixedSuites(RRR^RT((s./usr/lib/python2.7/site-packages/nose/suite.pyR_�s	
 ccs�tjd|�|dkr dSt|d�r;|j}nt|d�rY|jj}nt|d�r}|jjd�}n8t|d�r�|j	jd�d }nt
d	|��x;|r�tjd
||�tdj|��V|j
�q�WdS(s�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.
        sget ancestry %sNtim_classt__self__Rt.R
i����s%s has no ancestors?s %s ancestors %s(R%R&R)RuR�R�RRtsplitR
t	TypeErrorRtjoinR|(RRTRm((s./usr/lib/python2.7/site-packages/nose/suite.pytancestry�s 	cCs�t|�st|tj�r"dSd}xl|D]d}t|dd�}|dkrYq/n|dkrn|}q/||kr/td||f��q/q/W|S(NRTs5Tests with different contexts in same suite! %s != %s(R2R/R0R1R)R[R(RRRTR tctx((s./usr/lib/python2.7/site-packages/nose/suite.pyR��s
	cKs�|j|d|d|jd|d|j|�}|dk	r�|jj|g�j|�|jj|g�j|�tj	d|t
|dd��x`|j|�D]L}|jj|g�j|�|j|j|�tj	d||j�q�Wn|S(NRTRVRURWssuite %s has context %sR
ssuite %s has ancestor %s(
R�RVRWR)R�t
setdefaultRRTR%R&R[R�R
(RRRTR^tsuiteRn((s./usr/lib/python2.7/site-packages/nose/suite.pyR��scCs�|s
gS|jd�}|s&|gS|}|}t|dd�}|dk	r�|gg|j|�D]}|^qg}x|D]�}|g}	g}
x�|D]�}t}t|dd�}
|
dkr�|
j|�q�n|
|kr�|	j|�q�nx:|j|
�D])}||kr	|	j|�t}Pq	q	W|s�|
j|�q�q�W|	rk|j|	|�}n|j|
�}q�Wn|g|S(scThe 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.
        iRTN(	R|R[R)R�R*RR'R�R�(RRtheadR�ttailRTtaRmRntcommontremainR tfound_commonttest_ctxt
test_ancestor((s./usr/lib/python2.7/site-packages/nose/suite.pyR��sB)
	



c
Cs�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(Nswrap %ssI won't wrapswrapping %sRTRVRW(
R%R&R2R/R0R1RRtContextListR�RTRVRW(RRtwrappedR ((s./usr/lib/python2.7/site-packages/nose/suite.pyR�s

!"#N(R
RRR7R�R)R�RR_R�R�R�R�R�(((s./usr/lib/python2.7/site-packages/nose/suite.pyR��s					2R�cBs#eZdZdd�Zd�ZRS(s�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.
    cCs||_||_dS(N(RRT(RRRT((s./usr/lib/python2.7/site-packages/nose/suite.pyR2s	cCs
t|j�S(N(RR(R((s./usr/lib/python2.7/site-packages/nose/suite.pyR6sN(R
RRR)RR(((s./usr/lib/python2.7/site-packages/nose/suite.pyR�-stFinalizingSuiteWrappercBs2eZdZd�Zd�Zd�Zd�ZRS(s�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.
    cCs)tt|�j�||_||_dS(N(RR�RR�tfinalize(RR�R�((s./usr/lib/python2.7/site-packages/nose/suite.pyR@s	cOs|j||�S(N(R$(RR]R^((s./usr/lib/python2.7/site-packages/nose/suite.pyR_EscCs
t|j�S(N(RR�(R((s./usr/lib/python2.7/site-packages/nose/suite.pyRIscOs,z|j||�SWd|j||�XdS(N(R�R�(RR]R^((s./usr/lib/python2.7/site-packages/nose/suite.pyR$Ls(R
RRRR_RR$(((s./usr/lib/python2.7/site-packages/nose/suite.pyR�:s
			tTestDircBseZd�ZRS(cOstd��dS(Ns�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.(tNotImplementedError(R]R^((s./usr/lib/python2.7/site-packages/nose/suite.pyRUs(R
RR(((s./usr/lib/python2.7/site-packages/nose/suite.pyR�Tst
TestModulecBseZd�ZRS(cOstd��dS(Ns�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^((s./usr/lib/python2.7/site-packages/nose/suite.pyR]s(R
RR(((s./usr/lib/python2.7/site-packages/nose/suite.pyR�\s(&Rt
__future__RtloggingR`R0t	nose.caseRtnose.configRt
nose.proxyRt	nose.utilRRRRbtversion_infotclrtAddReferencetIronPython.Runtime.ExceptionsR	t	Exceptiont	getLoggerR
R%RR�R
RR1RR7R�R�R�R�R�(((s./usr/lib/python2.7/site-packages/nose/suite.pyt<module>	s4
		K�	�