ó K9•Qc@sðdZddlZddlZddlZddlmZddlmZddlm Z ddl m Z m Z m Z ejeƒZdgZdejfd„ƒYZd ejfd „ƒYZd efd „ƒYZd efd„ƒYZdS(sÞnose unittest.TestCase subclasses. It is not necessary to subclass these classes when writing tests; they are used internally by nose.loader.TestLoader to create test cases from test functions and methods in test classes. iÿÿÿÿN(t isfunction(tConfig(tFailure(t resolve_namet test_addressttry_runtTestcBs¤eZdZeZddd„Zd„Zd„Zd„Z d„Z d„Z d„Z d„Z d „Zd „Zeeddd ƒZd „Zd „Zd„ZRS(såThe universal test case wrapper. When a plugin sees a test, it will always see an instance of this class. To access the actual test case that will be run, access the test property of the nose.case.Test instance. cCst|ƒstd|ƒ‚n||_|dkr@tƒ}n||_d|_d|_||_|j |_ d|_ t j j |ƒdS(NsTnose.case.Test called with argument %r that is not callable. A callable is required.(tcallablet TypeErrorttesttNoneRtconfigttbinfotcapturedOutputt resultProxytpluginstpassedtunittesttTestCaset__init__(tselfR R R((s-/sys/lib/python2.7/site-packages/nose/case.pyRs           cOs|j||ŽS(N(trun(Rtargtkwarg((s-/sys/lib/python2.7/site-packages/nose/case.pyt__call__,scCs/|jj|ƒ}|dk r"|St|jƒS(N(RttestNameR tstrR (Rtname((s-/sys/lib/python2.7/site-packages/nose/case.pyt__str__/s cCs d|jS(NsTest(%r)(R (R((s-/sys/lib/python2.7/site-packages/nose/case.pyt__repr__5scCs2y |j}Wntk r nX||jƒdS(s>Called after test is complete (after result.stopTest) N(t afterTesttAttributeErrorR (RtresultR((s-/sys/lib/python2.7/site-packages/nose/case.pyR8s   cCs2y |j}Wntk r nX||jƒdS(s<Called before test is run (before result.startTest) N(t beforeTestRR (RR R!((s-/sys/lib/python2.7/site-packages/nose/case.pyR!Bs   cCs"tjƒ\}}}|||fS(s Extract exception info. (tsystexc_info(Rtexctexvttb((s-/sys/lib/python2.7/site-packages/nose/case.pyR#LscCs |jjƒS(s0Get a short(er) description of the test (R tid(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR'RscCs0t|jdƒr|jjƒSt|jƒSdS(sÈReturn a round-trip name for this test, a name that can be fed back as input to loadTestByName and (assuming the same plugin configuration) result in the loading of this test. taddressN(thasattrR R(R(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR(Ws cCspy|jjSWntk r!nXy|jjSWntk rCnXyt|jjƒSWntk rknXdS(N(R tcontextRt __class__Rt __module__R (R((s-/sys/lib/python2.7/site-packages/nose/case.pyt_contextbs   s-Get the context object of this test (if any).cCsŽ|jr|j||ƒ}nz[y|j|ƒ|j|ƒWn6tk rU‚n#tjƒ}|j||ƒnXWd|j|ƒXdS(sModified run for the test wrapper. From here we don't call result.startTest or stopTest or addSuccess. The wrapper calls addError/addFailure only if its own setup or teardown fails, or running the wrapped test fails (eg, if the wrapped "test" is not callable). Two additional methods are called, beforeTest and afterTest. These give plugins a chance to modify the wrapped test before it is called and do cleanup after it is called. They are called unconditionally. N(RR!trunTesttKeyboardInterruptR"R#taddErrorR(RR terr((s-/sys/lib/python2.7/site-packages/nose/case.pyRss    cCsA|j}|jjj|ƒ}|dk r3|}n||ƒdS(sºRun the test. Plugins may alter the test by returning a value from prepareTestCase. The value must be callable and must accept one argument, the result instance. N(R R RtprepareTestCaseR (RR R t plug_test((s-/sys/lib/python2.7/site-packages/nose/case.pyR.Žs    cCsÛ|jj|ƒ}|dk r"|S|j}y|jjƒ|_Wn;tk r~y|jjƒ|_Wqtk rzqXnXy|jjƒ}Wnt k r¥nXy|t |jƒkrÂdSWnt k rÖnX|S(N( Rt describeTestR R t_testMethodDoctstripRt_TestCase__testMethodDoctshortDescriptiont ExceptionR(RtdescR ((s-/sys/lib/python2.7/site-packages/nose/case.pyR8™s*      N(t__name__R,t__doc__tFalset__test__R RRRRRR!R#R'R(R-tpropertyR*RR.R8(((s-/sys/lib/python2.7/site-packages/nose/case.pyRs"          tTestBasecBs/eZdZeZd„Zd„Zd„ZRS(sBCommon functionality for FunctionTestCase and MethodTestCase. cCs t|ƒS(N(R(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR'ÁscCs|j|jŒdS(N(R R(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR.ÄscCsrt|jdƒr|jjS|jƒ\}}t|ddƒ}|sUt|ƒ}n|jƒjdƒdjƒS(Nt descriptionR<s i( R)R RAt _descriptorstgetattrR RR6tsplit(RtfuncRtdoc((s-/sys/lib/python2.7/site-packages/nose/case.pyR8Çs (R;R,R<R=R>R'R.R8(((s-/sys/lib/python2.7/site-packages/nose/case.pyR@¼s   tFunctionTestCasecBs}eZdZeZd d eƒd d„Zd„Zd„Z e e d d dƒZ d„Z d„Z d„ZeZd„ZRS( s˜TestCase wrapper for test functions. Don't use this class directly; it is used internally in nose to create test cases for test functions. cCs>||_||_||_||_||_tj|ƒdS(sInitialize the MethodTestCase. Required argument: * test -- the test function to call. Optional arguments: * setUp -- function to run at setup. * tearDown -- function to run at teardown. * arg -- arguments to pass to the test function. This is to support generator functions that yield arguments. * descriptor -- the function, other than the test, that should be used to construct the test name. This is to support generator functions. N(R t setUpFunct tearDownFuncRt descriptorR@R(RR tsetUpttearDownRRJ((s-/sys/lib/python2.7/site-packages/nose/case.pyRÙs      cCs-|jdk rt|jƒSt|jƒSdS(sÈReturn a round-trip name for this test, a name that can be fed back as input to loadTestByName and (assuming the same plugin configuration) result in the loading of this test. N(RJR RR (R((s-/sys/lib/python2.7/site-packages/nose/case.pyR(õs cCst|jjƒS(N(RR R,(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR-ÿss!Get context (module) of this testcCs0|jr|jƒnd}t|j|ƒdS(s=Run any setup function attached to the test function tsetupRKRHN(ssetupssetUps setUpFunc(RHRR (Rtnames((s-/sys/lib/python2.7/site-packages/nose/case.pyRKs  cCs0|jr|jƒnd}t|j|ƒdS(s@Run any teardown function attached to the test function tteardownRLRIN(ROstearDowns tearDownFunc(RIRR (RRN((s-/sys/lib/python2.7/site-packages/nose/case.pyRL s  cCsf|jƒ\}}t|dƒr-|j}n |j}d|j|f}|rbd||f}n|S(Ntcompat_func_names%s.%ss%s%s(RBR)RPR;R,(RRERR((s-/sys/lib/python2.7/site-packages/nose/case.pyRs  cCs-|jr|j|jfS|j|jfSdS(sfGet the descriptors of the test function: the function and arguments that will be used to construct the test name. In most cases, this is the function itself and no arguments. For tests generated by generator functions, the original (generator) function and args passed to the generated function are returned. N(RJRR (R((s-/sys/lib/python2.7/site-packages/nose/case.pyRB%s N(R;R,R<R=R>R ttupleRR(R-R?R*RKRLRRRB(((s-/sys/lib/python2.7/site-packages/nose/case.pyRGÑs      tMethodTestCasecBszeZdZeZd eƒd d„Zd„ZeZ d„Z d„Z e e d d dƒZ d„Zd„Zd„ZRS( s•Test case wrapper for test methods. Don't use this class directly; it is used internally in nose to create test cases for test methods. cCsž||_||_||_||_t|ƒr?tdƒ‚n|j|_|jƒ|_|jdkr|jj }t |j|ƒ|_nt j |ƒdS(s¤Initialize the MethodTestCase. Required argument: * method -- the method to call, may be bound or unbound. In either case, a new instance of the method's class will be instantiated to make the call. Note: In Python 3.x, if using an unbound method, you must wrap it using pyversion.unbound_method. Optional arguments: * test -- the test function to call. If this is passed, it will be called instead of getting a new bound method of the same name as the desired method from the test instance. This is to support generator methods that yield inline functions. * arg -- arguments to pass to the test function. This is to support generator methods that yield arguments. * descriptor -- the function, other than the test, that should be used to construct the test name. This is to support generator methods. s_Unbound methods must be wrapped using pyversion.unbound_method before passing to MethodTestCaseN(tmethodR RRJRt ValueErrortim_classtclstinstR R;RCR@R(RRSR RRJt method_name((s-/sys/lib/python2.7/site-packages/nose/case.pyR;s       cCsr|jƒ\}}t|dƒr-|j}n |j}d|jj|jj|f}|rnd||f}n|S(NRPs%s.%s.%ss%s%s(RBR)RPR;RVR,(RRERR((s-/sys/lib/python2.7/site-packages/nose/case.pyR_s     cCs-|jdk rt|jƒSt|jƒSdS(sÈReturn a round-trip name for this test, a name that can be fed back as input to loadTestByName and (assuming the same plugin configuration) result in the loading of this test. N(RJR RRS(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR(ms cCs|jS(N(RV(R((s-/sys/lib/python2.7/site-packages/nose/case.pyR-wss Get context (class) of this testcCst|jdƒdS(NRMRK(ssetupssetUp(RRW(R((s-/sys/lib/python2.7/site-packages/nose/case.pyRK|scCst|jdƒdS(NRORL(steardownstearDown(RRW(R((s-/sys/lib/python2.7/site-packages/nose/case.pyRLscCs-|jr|j|jfS|j|jfSdS(sgGet the descriptors of the test method: the method and arguments that will be used to construct the test name. In most cases, this is the method itself and no arguments. For tests generated by generator methods, the original (generator) method and args passed to the generated method or function are returned. N(RJRRS(R((s-/sys/lib/python2.7/site-packages/nose/case.pyRB‚s N(R;R,R<R=R>R RQRRRR(R-R?R*RKRLRB(((s-/sys/lib/python2.7/site-packages/nose/case.pyRR3s$      (R<tloggingR"RtinspectRt nose.configRt nose.failureRt nose.utilRRRt getLoggerR;tlogt__all__RRR@RGRR(((s-/sys/lib/python2.7/site-packages/nose/case.pyts    ©b