ó J9•Qc@sÈdZddlmZddlZddlZddlZddlmZddlm Z ddl m Z ddl 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./sys/lib/python2.7/site-packages/nose/suite.pyR scCsd|j|jfS(Ns%s.%s(R R (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 R t__doc__(((s./sys/lib/python2.7/site-packages/nose/suite.pyR'st LazySuitecBs}eZdZd d„Zd„Zd„Zd„ZeZd„Zd„Z d„Z d„Z d „Z e e e d d ƒ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  cCstjdt|ƒƒ|jr#tS|jdkr6tSy3|jjƒ}|dk rh|jj |ƒtSWnt k r|nXtS(Ns tests 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 R RRRRRt__str__R R#R,R-RtpropertyR(R(((s./sys/lib/python2.7/site-packages/nose/suite.pyR.s         t ContextSuitecBs eZdZejjZeZeZd.Z d/Z d0Z d1Z 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. t setup_classt setup_allt setupClasstsetupAllt setUpClasstsetUpAlltteardown_classt teardown_allt teardownClasst teardownAllt tearDownClasst tearDownAllt setup_modulet setupModulet setUpModuletsetuptsetUptteardown_moduletteardownModulettearDownModuletteardownttearDownt setup_packaget setupPackaget setUpPackagetteardown_packagetteardownPackagettearDownPackagecCs‡tjd||t|ƒƒ||_||_|dkrFtƒ}n||_||_t |_ ||_ d|_ t j||ƒdS(NsContext suite for %s (%s) (%s)(R$R%RtcontexttfactoryR(Rtconfigt resultProxyR)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Ÿs cCs.|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(Nt ctx_callback(RSR(R)timplementsAnyFixtureR&RTtget(RRiRSRTt ancestorstancestor((s./sys/lib/python2.7/site-packages/nose/suite.pyt hasFixturesê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 classTeardownt moduleSetuptmoduleTeardownthasattrt packageSetuptpackageTeardownR)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(RTRktpopt setupContextR&(RRSRTRlRm((s./sys/lib/python2.7/site-packages/nose/suite.pyRG s2        cCs©|jjj|ƒtjd||ƒ|jrX||jjkrEdS||jj|R?R@RARB(RCRDREssetupssetUp(RHRIRJsteardownstearDown(RMRNRO(RPRQRR(N(&R R RR/tTestCasetfailureExceptionR)RzR€RpRqRrRsRuRvR(R&RRR4RRR^R`RdR#RnRjRGR|RRLRRƒR5RRR(((s./sys/lib/python2.7/site-packages/nose/suite.pyR6xsF         &     !  tContextSuiteFactorycBs\eZdZeZdded„Zd„Zd„Z d„Z d„Z d„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(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 wrapTestst findContextRt makeSuitet mixedSuites(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òtjd ||ƒt dj |ƒƒ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__R t.R iÿÿÿÿs%s has no ancestors?s %s ancestors %s(R$R%R(RtRŽRRR tsplitR 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     c Ksú|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ŒØ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| ƒqn| |krù| j| ƒqnx:|j| ƒD])}||kr | j| ƒt} Pq q W| s| j| ƒqqW| rk|j| |ƒ}n|j| ƒ}qWn|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—ttailRStaRlRmtcommontremainRt found_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|j d|j ƒƒqLW|S(Nswrap %ss I won't wraps wrapping %sRSRURV( R$R%R1R.R/R0RRt ContextListRŒRSRURV(RRtwrappedR((s./sys/lib/python2.7/site-packages/nose/suite.pyRŠs  !"#N(R R RR6R‡R(RˆRR^R”R‹RŒRRŠ(((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 R RR(RR(((s./sys/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||_||_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 R RRR^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 R R(((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 R R(((s./sys/lib/python2.7/site-packages/nose/suite.pyR¦Zs(&Rt __future__RtloggingR_R/t nose.caseRt nose.configRt nose.proxyRt nose.utilRRRRat version_infotclrt AddReferencetIronPython.Runtime.ExceptionsR t Exceptiont getLoggerR R$RRˆR RR0RR6R†R R¢R¤R¦(((s./sys/lib/python2.7/site-packages/nose/suite.pyt s4       Jÿ ¬