U e#@sdZddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z e eZdddgZejjZejjZejjZejjZejjZejjZGdddeZeZ Gd ddeZ!dS) z 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. N)Config)split_test_namesrc getfilename getpackage ispackage is_executableSelectordefaultSelector TestAddressc@sXeZdZdZddZddZddZdd Zd d Zd d Z ddZ ddZ ddZ dS)r zCore test selector. Examines test candidates and determines whether, given the specified configuration, the test candidate should be selected as a test. cCs|dkrt}||dSN)r configureselfconfigr;/opt/hc_python/lib/python3.8/site-packages/nose/selector.py__init__"szSelector.__init__cCs2||_|j|_|j|_|j|_|j|_|j|_dSr )rexclude ignoreFilesincludepluginsZ testMatchmatchrrrrr 's zSelector.configurecsX|js0|joVddfdd|jDDoV|j pVddfdd|jDD S)zDoes the name match my requirements? To match, a name must match config.testMatch OR config.include and it must not match config.exclude cSsg|] }|r|qSrr.0Z_frrr 7sz$Selector.matches..csg|]}|qSrsearch)rincnamerrr7scSsg|] }|r|qSrrrrrrr9scsg|]}|qSrrrexcrrrr9s)rrrr)rr rrrmatches/s zSelector.matchescCsxt|dd}|dk r|}n&|jd o>t|tjp>||j}|j|}|dk rft d|||}t d|||S)zIs 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. __test__N_$Plugin setting selection of %s to %szwantClass %s? %s) getattr__name__ startswith issubclassunittestZTestCaser#r wantClasslogdebug)rclsdeclaredwanted plug_wantsrrrr,<s    zSelector.wantClasscst|t|r:|j p6ddfdd|jDD }n|pV|jjoV|jjk}|j|}|dk r~t d|||}t d|||S)zIs 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. cSsg|] }|r|qSrrrrrrrZsz*Selector.wantDirectory..csg|]}|qSrrr!tailrrrZsNr&zwantDirectory %s? %s) op_basenamerrr#rZsrcDirsr wantDirectoryr-r.)rdirnamer1r2rr3rr6Qs$   zSelector.wantDirectorycst|fdd|jD}|r0tddS|jjsPt|rPtd|dSt\}}|dk}|op| }|j |}|dk rtd|||}td |||S) aIs 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. csg|]}|r|qSrr)rZ ignore_thisbaserrrqs z%Selector.wantFile..z'%s matches ignoreFiles pattern; skippedFz%s is executable; skippedz.pyNzplugin setting want %s to %szwantFile %s? %s) r5rr-r.rZ includeExerinfo op_splitextr#rwantFile)rfileZignore_matchesdummyextZpysrcr1r2rr8rr<gs&    zSelector.wantFilecCszt|dr|j}n|j}Wntk r2YdSXt|dd}|dk rN|}n|d ob||}|j|}|dk r||}t d|||S)z)Is the function a test function? compat_func_nameFr$Nr%zwantFunction %s? %s) hasattrr@r(AttributeErrorr'r)r#r wantFunctionr-r.)rfunctionfuncnamer0r1r2rrrrCs    zSelector.wantFunctioncCs~z |j}Wntk r YdSX|dr0dSt|dd}|dk rJ|}n ||}|j|}|dk rl|}td|||S)z%Is the method a test method? Fr%r$NzwantMethod %s? %s) r(rBr)r'r#r wantMethodr-r.)rmethod method_namer0r1r2rrrrFs     zSelector.wantMethodcCsdt|dd}|dk r|}n ||jddp8|jdk}|j|}|dk rR|}td|||S)zIs the module a test module? The tail of the module name must match test requirements. One exception: we always want __main__. r$N.__main__zwantModule %s? %s)r'r#r(splitr wantModuler-r.)rmoduler0r1r2rrrrMs  zSelector.wantModuleN) r( __module__ __qualname____doc__rr r#r,r6r<rCrFrMrrrrr s c@s2eZdZdZd ddZddZddZd d ZdS) r aA 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. NcCs|dkrt}||_||_t|\|_|_|_t d||j|j|j|jdkrl|jdk rlt |j|j|_|jrt |j|_t |jst t||j|_|jdkrt|j|_t d||j|j|jdS)Nz4Test name %s resolved to file %s, module %s, call %sz;Final resolution of test name %s: file %s module %s call %s)osgetcwdr workingDirrfilenamerNcallr-r.rrop_isabs op_abspathop_joinr)rr rTrrrrs:      zTestAddress.__init__cCs|j|j|jfSr )rUrNrVrrrrtotupleszTestAddress.totuplecCs|jSr rrZrrr__str__szTestAddress.__str__cCsd|j|j|j|jfS)Nz%s: (%s, %s, %s))r rUrNrVrZrrr__repr__s zTestAddress.__repr__)N)r(rOrPrQrr[r\r]rrrrr s  )"rQloggingrRr+Z nose.configrZ nose.utilrrrrrr getLoggerr(r-__all__pathjoinrYbasenamer5existsZ op_existssplitextr;isabsrWabspathrXobjectr r r rrrrs"    '