ó J9•Qc@sþdZddlZddlZddlZddlmZddlmZmZm Z m Z m Z ej e ƒZdddgZejjZejjZejjZejjZejjZejjZdefd„ƒYZeZdefd „ƒYZ dS( s» Test Selection -------------- Test selection is handled by a Selector. The test loader calls the appropriate selector method for each object it encounters that it thinks may be a test. iÿÿÿÿN(tConfig(tsplit_test_nametsrct getfilenamet getpackaget ispackagetSelectortdefaultSelectort TestAddresscBs_eZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z RS( s¥Core test selector. Examines test candidates and determines whether, given the specified configuration, the test candidate should be selected as a test. cCs)|dkrtƒ}n|j|ƒdS(N(tNoneRt configure(tselftconfig((s1/sys/lib/python2.7/site-packages/nose/selector.pyt__init__"s  cCsI||_|j|_|j|_|j|_|j|_|j|_dS(N(R texcludet ignoreFilestincludetpluginst testMatchtmatch(R R ((s1/sys/lib/python2.7/site-packages/nose/selector.pyR 's      c Cs€|jj|ƒsI|jotdg|jD]}|j|ƒ^q+ƒo|j ptdg|jD]}|j|ƒ^qcƒ S(s¢Does the name match my requirements? To match, a name must match config.testMatch OR config.include and it must not match config.exclude N(RtsearchRtfilterR R(R tnametinctexc((s1/sys/lib/python2.7/site-packages/nose/selector.pytmatches/s ( cCs¯t|ddƒ}|dk r'|}n7|jjdƒ o[t|tjƒp[|j|jƒ}|jj |ƒ}|dk r˜t j d||ƒ|}nt j d||ƒ|S(s¹Is the class a wanted test class? A class must be a unittest.TestCase subclass, or match test name requirements. Classes that start with _ are always excluded. t__test__t_s$Plugin setting selection of %s to %sswantClass %s? %sN( tgetattrR t__name__t startswitht issubclasstunittesttTestCaseRRt wantClasstlogtdebug(R tclstdeclaredtwantedt plug_wants((s1/sys/lib/python2.7/site-packages/nose/selector.pyR">s    cCsÒt|ƒ}t|ƒrT|j pNtdg|jD]}|j|ƒ^q2ƒ }n-|j|ƒp~|jjo~||jjk}|j j |ƒ}|dk r»t j d||ƒ|}nt j d||ƒ|S(s½Is the directory a wanted test directory? All package directories match, so long as they do not match exclude. All other directories must match test requirements. s$Plugin setting selection of %s to %sswantDirectory %s? %sN( t op_basenameRRRR RRR tsrcDirsRt wantDirectoryR#R$(R tdirnamettailRR'R(((s1/sys/lib/python2.7/site-packages/nose/selector.pyR+Ss   ,     c Cs t|ƒ}g|jD]}|j|ƒr|^q}|rQtjd|ƒtS|jj r‡tj |tj ƒr‡tj d|ƒtSt |ƒ\}}|dk}|o·|j |ƒ}|jj|ƒ} | dk rôtjd|| ƒ| }ntjd||ƒ|S(sIs the file a wanted test file? The file must be a python source file and match testMatch or include, and not match exclude. Files that match ignore are *never* wanted, regardless of plugin, testMatch, include or exclude settings. s'%s matches ignoreFiles pattern; skippeds%s is executable; skippeds.pysplugin setting want %s to %sswantFile %s? %sN(R)RRR#R$tFalseR t includeExetostaccesstX_OKtinfot op_splitextRRtwantFileR ( R tfiletbaset ignore_thistignore_matchestdummytexttpysrcR'R(((s1/sys/lib/python2.7/site-packages/nose/selector.pyR5ks&  "   cCsÁy(t|dƒr|j}n |j}Wntk r<tSXt|ddƒ}|dk rd|}n|jdƒ o€|j|ƒ}|j j |ƒ}|dk rª|}nt j d||ƒ|S(s)Is the function a test function? tcompat_func_nameRRswantFunction %s? %sN( thasattrR=RtAttributeErrorR.RR RRRt wantFunctionR#R$(R tfunctiontfuncnameR&R'R(((s1/sys/lib/python2.7/site-packages/nose/selector.pyR@‰s       cCs©y |j}Wntk r!tSX|jdƒr5tSt|ddƒ}|dk r\|}n|j|ƒ}|jj|ƒ}|dk r’|}nt j d||ƒ|S(s%Is the method a test method? RRswantMethod %s? %sN( RR?R.RRR RRt wantMethodR#R$(R tmethodt method_nameR&R'R(((s1/sys/lib/python2.7/site-packages/nose/selector.pyRCŸs      cCs“t|ddƒ}|dk r'|}n.|j|jjdƒdƒpR|jdk}|jj|ƒ}|dk r||}ntjd||ƒ|S(s˜Is the module a test module? The tail of the module name must match test requirements. One exception: we always want __main__. Rt.iÿÿÿÿt__main__swantModule %s? %sN( RR RRtsplitRt wantModuleR#R$(R tmoduleR&R'R(((s1/sys/lib/python2.7/site-packages/nose/selector.pyRIµs    ( Rt __module__t__doc__R R RR"R+R5R@RCRI(((s1/sys/lib/python2.7/site-packages/nose/selector.pyRs        cBs5eZdZdd„Zd„Zd„Zd„ZRS(s±A test address represents a user's request to run a particular test. The user may specify a filename or module (or neither), and/or a callable (a class, function, or method). The naming format for test addresses is: filename_or_module:callable Filenames that are not absolute will be made absolute relative to the working dir. The filename or module part will be considered a module name if it doesn't look like a file, that is, if it doesn't exist on the file system and it doesn't contain any directory separators and it doesn't end in .py. Callables may be a class name, function name, method name, or class.method specification. cCs>|dkrtjƒ}n||_||_t|ƒ\|_|_|_t j d||j|j|jƒ|jdkr©|jdk r©t |j|jƒ|_q©n|jrt |jƒ|_t |jƒsñtt||jƒƒ|_n|jdkrt|jƒ|_qnt j d||j|j|jƒdS(Ns4Test name %s resolved to file %s, module %s, call %ss;Final resolution of test name %s: file %s module %s call %s(R R0tgetcwdRt workingDirRtfilenameRJtcallR#R$RRtop_isabst op_abspathtop_joinR(R RRN((s1/sys/lib/python2.7/site-packages/nose/selector.pyR Ýs(      cCs|j|j|jfS(N(RORJRP(R ((s1/sys/lib/python2.7/site-packages/nose/selector.pyttotupleóscCs|jS(N(R(R ((s1/sys/lib/python2.7/site-packages/nose/selector.pyt__str__öscCs d|j|j|j|jfS(Ns%s: (%s, %s, %s)(RRORJRP(R ((s1/sys/lib/python2.7/site-packages/nose/selector.pyt__repr__ùsN(RRKRLR R RTRURV(((s1/sys/lib/python2.7/site-packages/nose/selector.pyRÊs    (!RLtloggingR0R t nose.configRt nose.utilRRRRRt getLoggerRR#t__all__tpathtjoinRStbasenameR)texistst op_existstsplitextR4tisabsRQtabspathRRtobjectRRR(((s1/sys/lib/python2.7/site-packages/nose/selector.pyts    (      ª