�9�c@s�dZddlmZddlZddlZddlZddlmZddlm Z ddl
mZddlm
Z
mZmZejdkr�jd d d
fkr�ddlZejd�ddlmZnd
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(tisclasstresolve_namettry_runtcliiit
IronPython(tStringExceptionR cBseZRS((t__name__t
__module__(((s./sys/lib/python2.7/site-packages/nose/suite.pyR scCsd|j|jfS(Ns%s.%s(RR
(tcls((s./sys/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./sys/lib/python2.7/site-packages/nose/suite.pyR'st LazySuitecBs}eZdZdd�Zd�Zd�Zd�ZeZd�Zd�Z d�Z
d�Zd �Ze
eedd
�ZRS(
s:A suite that may use a generator as its list of tests
cCs|j|�dS(sFInitialize the suite. tests may be an iterable or a generator
N(t
_set_tests(tselfttests((s./sys/lib/python2.7/site-packages/nose/suite.pyt__init__1scCs
t|j�S(N(titert_tests(R((s./sys/lib/python2.7/site-packages/nose/suite.pyt__iter__6scCsdt|j�t|�fS(Ns<%s tests=generator (%s)>(R
t __class__tid(R((s./sys/lib/python2.7/site-packages/nose/suite.pyt__repr__9scCs
tj|�S(N(tobjectt__hash__(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR=scCs|jj|�dS(N(t _precachetappend(Rttest((s./sys/lib/python2.7/site-packages/nose/suite.pytaddTestBscCs/x(|jD]}|jrPn||�q
W|S(N(Rt
shouldStop(RtresultR((s./sys/lib/python2.7/site-packages/nose/suite.pytrunFs
cCs�tjdt|��|jr#tS|jdkr6tSy3|jj�}|dk rh|jj |�tSWnt
k
r|nXtS(Nstests in %s?(tlogtdebugRRtTruettest_generatortNonetFalsetnextRt
StopIteration(RR((s./sys/lib/python2.7/site-packages/nose/suite.pyt__nonzero__Ms
ccs\tjd|j�x|jD]}|VqW|jdkr?dSx|jD]}|VqIWdS(Nsprecache is %s(R$R%RR'R((RR((s./sys/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./sys/lib/python2.7/site-packages/nose/suite.pyRes
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./sys/lib/python2.7/site-packages/nose/suite.pyR.s tContextSuitecBs
eZdZejjZeZeZd.Z d/Z
d0Zd1Zd2Z
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_classtteardown_allt
teardownClasstteardownAllt
tearDownClassttearDownAlltsetup_moduletsetupModuletsetUpModuletsetuptsetUptteardown_moduletteardownModulettearDownModuletteardownttearDownt
setup_packagetsetupPackagetsetUpPackagetteardown_packagetteardownPackagettearDownPackagecCs�tjd||t|��||_||_|dkrFt�}n||_||_t |_
||_d|_t
j||�dS(NsContext suite for %s (%s) (%s)(R$R%RtcontexttfactoryR(RtconfigtresultProxyR)thas_runt can_splitt
error_contextRR(RRRSRTRURVRX((s./sys/lib/python2.7/site-packages/nose/suite.pyR�s cCs)dt|j�t|jd|j�fS(Ns<%s context=%s>R
(R
RtgetattrRS(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR�scCs.|jr dt|�|jfSt|�SdS(Ns%s:%s(RYtrepr(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR�s cCs
tj|�S(N(RR(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR�scOs|j||�S(N(R#(Rtargtkw((s./sys/lib/python2.7/site-packages/nose/suite.pyt__call__�scCs
tj�S(s.Hook for replacing error tuple output
(tsystexc_info(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR`�scCsY|j�}tjdkrUt|dt�rUt|d�|d|df}qUn|S(s:Bottleneck to fix up IronPython string exceptions
Riii(R`R_tplatformR.R tstr(Rte((s./sys/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: %sRFNtstoppingRK(R$R%RRRVRGtKeyboardInterruptRYtaddErrorRdR!R&RWRL(RR"torigR((s./sys/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(Ntctx_callback(RSR(R)timplementsAnyFixtureR&RTtget(RRiRSRTt ancestorstancestor((s./sys/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
classTeardowntmoduleSetuptmoduleTeardownthasattrtpackageSetuptpackageTeardownR)R&R((RRSRitnamestfixttm((s./sys/lib/python2.7/site-packages/nose/suite.pyRj�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_setupRSR(RTRktpoptsetupContextR&(RRSRTRlRm((s./sys/lib/python2.7/site-packages/nose/suite.pyRGs2
cCs�|jjj|�tjd||�|jrX||jjkrEdS||jj|<nt|�rp|j}n(|j }t
|d�r�|j|}nt||�dS(Ns%s setup context %sRo(
RUtpluginststartContextR$R%RTRzRRpRrRtRuR(RRSRw((s./sys/lib/python2.7/site-packages/nose/suite.pyR|+s cCs|jdkrdSd|jS(Ns
test suitestest suite for %s(RSR((R((s./sys/lib/python2.7/site-packages/nose/suite.pytshortDescription<scCsVtjd�|js |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%Rztwas_torndownR&RSR(RTRktteardownContext(RRSRTRlRmRF((s./sys/lib/python2.7/site-packages/nose/suite.pyRLAs6
cCs�tjd||�|jrE||jjkr2dS||jj|<nt|�r]|j}n(|j}t|d�r�|j|}nt ||�|j
jj|�dS(Ns%s teardown context %sRo(
R$R%RTR�RRqRsRtRvRRUR}tstopContext(RRSRw((s./sys/lib/python2.7/site-packages/nose/suite.pyR�bs
ccsaxZ|j�D]L}t|t�s4t|tj�r<|Vq
t|d|jd|j�Vq
WdS(NRURV(R-R.RR/R0RURV(RR((s./sys/lib/python2.7/site-packages/nose/suite.pyt_get_wrapped_testsrs! sOAccess the tests in this suite. Tests are returned inside of a context wrapper.(R7R8R9R:R;R<(R=R>R?R@RARB(RCRDREssetupssetUp(RHRIRJsteardownstearDown(RMRNRO(RPRQRR(N(&R
RRR/tTestCasetfailureExceptionR)RzR�RpRqRrRsRuRvR(R&RRR4RRR^R`RdR#RnRjRGR|RRLR�R�R5RRR(((s./sys/lib/python2.7/site-packages/nose/suite.pyR6xsF
& ! tContextSuiteFactorycBs\eZdZeZdded�Zd�Zd�Z d�Z
d�Zd�Zd�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(NRU(R(RRUt
suiteClasst_defRRVtsuitesRSRzR�(RRUR�RV((s./sys/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 %sRSstests %s context %sN(
R$R%R{RZR(t wrapTeststfindContextRt makeSuitetmixedSuites(RRR]RS((s./sys/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�jd
||�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(RtR�R�RRtsplitR
t TypeErrorRtjoinR{(RRSRl((s./sys/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(NRSs5Tests with different contexts in same suite! %s != %s(R1R.R/R0R(RZR(RRRSRtctx((s./sys/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(NRSRURTRVssuite %s has context %sR
ssuite %s has ancestor %s(
R�RURVR(R�t
setdefaultRRSR$R%RZR�R
(RRRSR]tsuiteRm((s./sys/lib/python2.7/site-packages/nose/suite.pyR��scCs�|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.
iRSN( R{RZR(R�R)RR&R�R�(RRtheadR�ttailRStaRlRmtcommontremainRtfound_commonttest_ctxt
test_ancestor((s./sys/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 %ssI won't wrapswrapping %sRSRURV(
R$R%R1R.R/R0RRtContextListR�RSRURV(RRtwrappedR((s./sys/lib/python2.7/site-packages/nose/suite.pyR�s
!"#N(R
RRR6R�R(R�RR^R�R�R�R�R�(((s./sys/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(RRS(RRRS((s./sys/lib/python2.7/site-packages/nose/suite.pyR1s cCs
t|j�S(N(RR(R((s./sys/lib/python2.7/site-packages/nose/suite.pyR5sN(R
RRR(RR(((s./sys/lib/python2.7/site-packages/nose/suite.pyR�,stFinalizingSuiteWrappercBs2eZdZd�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||_||_dS(N(R�tfinalize(RR�R�((s./sys/lib/python2.7/site-packages/nose/suite.pyR?s cOs|j||�S(N(R#(RR\R]((s./sys/lib/python2.7/site-packages/nose/suite.pyR^CscCs
t|j�S(N(RR�(R((s./sys/lib/python2.7/site-packages/nose/suite.pyRGscOs,z|j||�SWd|j||�XdS(N(R�R�(RR\R]((s./sys/lib/python2.7/site-packages/nose/suite.pyR#Js(R
RRRR^RR#(((s./sys/lib/python2.7/site-packages/nose/suite.pyR�9s
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./sys/lib/python2.7/site-packages/nose/suite.pyRSs(R
RR(((s./sys/lib/python2.7/site-packages/nose/suite.pyR�Rst
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./sys/lib/python2.7/site-packages/nose/suite.pyR[s(R
RR(((s./sys/lib/python2.7/site-packages/nose/suite.pyR�Zs(&Rt
__future__RtloggingR_R/t nose.caseRtnose.configRt
nose.proxyRt nose.utilRRRRatversion_infotclrtAddReferencetIronPython.Runtime.ExceptionsR t Exceptiont getLoggerR
R$RR�R
RR0RR6R�R�R�R�R�(((s./sys/lib/python2.7/site-packages/nose/suite.pyt<module> s4
J��
|