ó JÑÕfc@sdZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z m Z e ZejdejƒZd„Zd „Zd „Zd efd „ƒYZeƒZed „Zed„Zdee jd„Zdee jd„ZdS(sLoading unittests.iÿÿÿÿN(t cmp_to_key(tfnmatchi(tcasetsuites[_a-z]\w*\.py$cCs/d|tjƒf}td|t|ƒ|ƒS(Ns#Failed to import test module: %s %stModuleImportFailure(t tracebackt format_exct_make_failed_testt ImportError(tnamet suiteClasstmessage((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_import_testscCstd|||ƒS(NtLoadTestsFailure(R(R t exceptionR ((s'/usr/lib64/python2.7/unittest/loader.pyt_make_failed_load_testsscsG‡fd†}i||6}t|tjf|ƒ}|||ƒfƒS(Ncs ˆ‚dS(N((tself(R(s'/usr/lib64/python2.7/unittest/loader.pyt testFailures(ttypeRtTestCase(t classnamet methodnameRR Rtattrst TestClass((Rs'/usr/lib64/python2.7/unittest/loader.pyRs t TestLoadercBs›eZdZdZeZejZdZ d„Z e d„Z dd„Zdd„Zd„Zddd„Zd „Zd „Zd „Zd „Zd „ZRS(s This class is responsible for loading tests according to various criteria and returning them wrapped in a TestSuite ttestcCsnt|tjƒr!tdƒ‚n|j|ƒ}| rRt|dƒrRdg}n|jt||ƒƒ}|S(s<Return a suite of all tests cases contained in testCaseClasssYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?trunTest(t issubclassRt TestSuitet TypeErrortgetTestCaseNamesthasattrR tmap(Rt testCaseClasst testCaseNamest loaded_suite((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromTestCase0s cCsÝg}x]t|ƒD]O}t||ƒ}t|tƒrt|tjƒr|j|j|ƒƒqqWt|ddƒ}|j |ƒ}|rÙ|dk rÙy|||dƒSWqÙt k rÕ}t |j ||j ƒSXn|S(s?Return a suite of all tests cases contained in the given modulet load_testsN(tdirtgetattrt isinstanceRRRRtappendR$tNoneR t ExceptionRt__name__(Rtmoduletuse_load_teststtestsR tobjR%te((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromModule;s! c CsÖ|jdƒ}|dkr}|}xK|roytdj|ƒƒ}PWq%tk rk|d=|sl‚qlq%Xq%W|d}n|}x$|D]}|t||ƒ}}qŠWt|tjƒrÉ|j |ƒSt|t ƒr÷t |t j ƒr÷|j|ƒSt|tjƒrCt|t ƒrCt |t j ƒrC|j||jƒgƒSt|tjƒrY|St|dƒrÂ|ƒ}t|tjƒr‡|St|t j ƒr©|j|gƒStd||fƒ‚ntd|ƒ‚dS(sTReturn a suite of all tests cases given a string specifier. The name may resolve either to a module, a test case class, a test method within a test case class, or a callable object which returns a TestCase or TestSuite instance. The method optionally resolves the names relative to a given module. t.iÿÿÿÿit__call__s"calling %s returned %s, not a tests$don't know how to make test from: %sN(tsplitR*t __import__tjoinRR'R(ttypest ModuleTypeR2RRRRR$tUnboundMethodTypeR R,RRRR( RR R-tpartst parts_copyR0tparttparentR((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNameMsD       !  cCs2g|D]}|j||ƒ^q}|j|ƒS(s‚Return a suite of all tests cases found using the given sequence of string specifiers. See 'loadTestsFromName()'. (R?R (RtnamesR-R tsuites((s'/usr/lib64/python2.7/unittest/loader.pytloadTestsFromNames|s%cCsP||jd„}t|t|ƒƒ}|jrL|jdt|jƒƒn|S(sLReturn a sorted sequence of method names found within testCaseClass cSs%|j|ƒo$tt||ƒdƒS(NR4(t startswithRR'(tattrnameR!tprefix((s'/usr/lib64/python2.7/unittest/loader.pyt isTestMethod†stkey(ttestMethodPrefixtfilterR&tsortTestMethodsUsingtsortt _CmpToKey(RR!RFt testFnNames((s'/usr/lib64/python2.7/unittest/loader.pyRƒs  stest*.pyc CsÄt}|dkr-|jdk r-|j}n|dkrHt}|}ntjj|ƒ}|tjkrtjjd|ƒn||_t}tjj tjj|ƒƒròtjj|ƒ}||kr†tjj tjj |dƒƒ }q†n”yt |ƒWnt k rt}nmXtj|}|jdƒd}tjjtjj|jƒƒ}|r†|j|ƒ|_tjj|ƒn|rŸt d|ƒ‚nt|j||ƒƒ}|j|ƒS(s+Find and return all test modules from the specified start directory, recursing into subdirectories to find them. Only test files that match the pattern will be loaded. (Using shell style pattern matching.) All test modules must be importable from the top level of the project. If the start directory is not the top level directory then the top level directory must be specified separately. If a test package name (directory with '__init__.py') matches the pattern then the package will be checked for a 'load_tests' function. If this exists then it will be called with loader, tests, pattern. If load_tests exists then discovery does *not* recurse into the package, load_tests is responsible for loading all tests in the package. The pattern is deliberately not stored as a loader attribute so that packages can continue discovery themselves. top_level_dir is stored so load_tests does not need to pass this argument in to loader.discover(). is __init__.pyR3s%Start directory is not importable: %rN(tFalseR*t_top_level_dirtTruetostpathtabspathtsystinserttisdirtisfileR7R6RtmodulesR5tdirnamet__file__t _get_directory_containing_moduletremovetlistt _find_testsR ( Rt start_dirtpatternt top_level_dirtset_implicit_toptis_not_importablet the_modulettop_partR/((s'/usr/lib64/python2.7/unittest/loader.pytdiscovers:     (   !cCsstj|}tjj|jƒ}tjj|ƒjƒjdƒr_tjj tjj |ƒƒStjj |ƒSdS(Ns __init__.py( RTRXRQRRRSRZtbasenametlowerRCRY(Rt module_nameR-t full_path((s'/usr/lib64/python2.7/unittest/loader.pyR[Ïs  !cCsVtjjtjj|ƒƒd}tjj||jƒ}|jtjjdƒ}|S(NiR3(RQRRtsplitexttnormpathtrelpathROtreplacetsep(RRRt_relpathR ((s'/usr/lib64/python2.7/unittest/loader.pyt_get_name_from_pathÛs"cCst|ƒtj|S(N(R6RTRX(RR ((s'/usr/lib64/python2.7/unittest/loader.pyt_get_module_from_nameås cCs t||ƒS(N(R(RRRRjR`((s'/usr/lib64/python2.7/unittest/loader.pyt _match_pathésccs¹tj|ƒ}x£|D]›}tjj||ƒ}tjj|ƒr‹tj|ƒsXqn|j|||ƒssqn|j|ƒ}y|j |ƒ}Wnt ||j ƒVq±Xtjj t |d|ƒƒ}tjj|ƒd} tjj|ƒd} | jƒ| jƒkrztjj| ƒ} tjjtjj|ƒƒd} tjj|ƒ} d}t|| | | fƒ‚n|j|ƒVqtjj|ƒrtjjtjj|dƒƒsÄqnd}d}t||ƒr'|j|ƒ}|j |ƒ}t |ddƒ}|j|dtƒ}n|dkrl|dk rG|Vnxd|j||ƒD] }|VqZWq±y||||ƒVWq±tk r­}t|j||j ƒVq±XqqWdS(s/Used by discovery. Yields test suites it loads.RZisW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?s __init__.pyR%R.N(RQtlistdirRRR7RWtVALID_MODULE_NAMEtmatchRsRqRrR R RSR'RkRhRYRgRR2RVR*RRNR^R+RR,(RR_R`tpathsRRRjR R-tmod_filetrealpathtfullpath_noextt module_dirtmod_namet expected_dirtmsgR%R/tpackageRR1((s'/usr/lib64/python2.7/unittest/loader.pyR^ísV "!    N(R,t __module__t__doc__RHtcmpRJRRR R*ROR$RPR2R?RBRRfR[RqRrRsR^(((s'/usr/lib64/python2.7/unittest/loader.pyR&s    /  @  cCs1tƒ}||_||_|r-||_n|S(N(RRJRHR (REt sortUsingR tloader((s'/usr/lib64/python2.7/unittest/loader.pyt _makeLoader)s     cCst||ƒj|ƒS(N(R…R(R!RERƒ((s'/usr/lib64/python2.7/unittest/loader.pyR1sRcCst|||ƒj|ƒS(N(R…R$(R!RERƒR ((s'/usr/lib64/python2.7/unittest/loader.pyt makeSuite4scCst|||ƒj|ƒS(N(R…R2(R-RERƒR ((s'/usr/lib64/python2.7/unittest/loader.pyt findTestCases8s(RRQtreRTRR8t functoolsRRLRtRRRPt __unittesttcompilet IGNORECASERuR RRtobjectRtdefaultTestLoaderR*R…R‚RRR†R‡(((s'/usr/lib64/python2.7/unittest/loader.pyts,        ÿ