Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/nose/__pycache__/selector.cpython-35.pyc



�^�]#�@sdZddlZddlZddlZddlmZddlmZmZm	Z	m
Z
mZmZej
e�ZdddgZejjZejjZejjZejjZejjZejjZGdd�de�ZeZ Gd	d�de�Z!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_name�src�getfilename�
getpackage�	ispackage�
is_executable�Selector�defaultSelector�TestAddressc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)r	z�Core test selector. Examines test candidates and determines whether,
    given the specified configuration, the test candidate should be selected
    as a test.
    cCs&|dkrt�}|j|�dS)N)r�	configure)�self�config�r�>/opt/alt/python35/lib/python3.5/site-packages/nose/selector.py�__init__"s	zSelector.__init__cCsI||_|j|_|j|_|j|_|j|_|j|_dS)N)r�exclude�ignoreFiles�include�pluginsZ	testMatch�match)r
rrrrr's	zSelector.configurecsv|jj��sD|joudd��fdd�|jD�D�ou|jpudd��fdd�|jD�D�S)z�Does 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)�.0�_frrr�
<listcomp>7s	z$Selector.matches.<locals>.<listcomp>csg|]}|j���qSr)�search)rZinc)�namerrr7s	cSsg|]}|r|�qSrr)rrrrrr9s	csg|]}|j���qSr)r)r�exc)rrrr9s	)rrrr)r
rr)rr�matches/s
	)
zSelector.matchescCs�t|dd�}|dk	r'|}n7|jjd�o[t|tj�p[|j|j�}|jj|�}|dk	r�t	j
d||�|}t	j
d||�|S)z�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.
        �__test__N�_z$Plugin setting selection of %s to %szwantClass %s? %s)�getattr�__name__�
startswith�
issubclass�unittest�TestCaserr�	wantClass�log�debug)r
�cls�declared�wanted�
plug_wantsrrrr&<s	zSelector.wantClasscs�t|��t|�rO|jpIdd��fdd�|jD�D�}n-|j��py|jjoy�|jjk}|jj|�}|dk	r�tj	d||�|}tj	d||�|S)z�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.
        cSsg|]}|r|�qSrr)rrrrrrZs	z*Selector.wantDirectory.<locals>.<listcomp>csg|]}|j���qSr)r)rr)�tailrrrZs	Nz$Plugin setting selection of %s to %szwantDirectory %s? %s)
�op_basenamerrrrZsrcDirsr�
wantDirectoryr'r()r
�dirnamer+r,r)r-rr/Qs
-	
zSelector.wantDirectorycs�t|���fdd�|jD�}|rBtjd��dS|jjrot|�rotjd|�dSt��\}}|dk}|o�|j	��}|j
j|�}|dk	r�tjd||�|}tjd	||�|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.
        cs%g|]}|j��r|�qSr)r)rZignore_this)�baserrrqs	z%Selector.wantFile.<locals>.<listcomp>z'%s matches ignoreFiles pattern; skippedFz%s is executable; skippedz.pyNzplugin setting want %s to %szwantFile %s? %s)r.rr'r(rZ
includeExer�info�op_splitextrr�wantFile)r
�fileZignore_matches�dummy�extZpysrcr+r,r)r1rr4gs$		zSelector.wantFilecCs�y(t|d�r|j}n	|j}Wntk
r@dSYnXt|dd�}|dk	rh|}n|jd�o�|j|�}|jj|�}|dk	r�|}t	j
d||�|S)z)Is the function a test function?
        �compat_func_nameFrNrzwantFunction %s? %s)�hasattrr8r!�AttributeErrorr r"rr�wantFunctionr'r()r
�function�funcnamer*r+r,rrrr;�s

		zSelector.wantFunctioncCs�y
|j}Wntk
r%dSYnX|jd�r9dSt|dd�}|dk	r`|}n|j|�}|jj|�}|dk	r�|}tjd||�|S)z%Is the method a test method?
        FrrNzwantMethod %s? %s)	r!r:r"r rr�
wantMethodr'r()r
�method�method_namer*r+r,rrrr>�s

		zSelector.wantMethodcCs�t|dd�}|dk	r'|}n.|j|jjd�d�pR|jdk}|jj|�}|dk	ry|}tjd||�|S)z�Is the module a test module?

        The tail of the module name must match test requirements. One exception:
        we always want __main__.
        rN�.��__main__zwantModule %s? %s���)r rr!�splitr�
wantModuler'r()r
�moduler*r+r,rrrrF�s	zSelector.wantModuleN)
r!�
__module__�__qualname__�__doc__rrrr&r/r4r;r>rFrrrrr	s
c@sIeZdZdZddd�Zdd�Zdd�Zd	d
�ZdS)ra�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.
    NcCs,|dkrtj�}||_||_t|�\|_|_|_tj	d||j|j|j�|jdkr�|jdk	r�t
|j|j�|_|jrt|j�|_t|j�s�t
t||j��|_|jdkrt|j�|_tj	d||j|j|j�dS)Nz4Test name %s resolved to file %s, module %s, call %sz;Final resolution of test name %s: file %s module %s call %s)�os�getcwdr�
workingDirr�filenamerG�callr'r(rr�op_isabs�
op_abspath�op_joinr)r
rrMrrrr�s(					zTestAddress.__init__cCs|j|j|jfS)N)rNrGrO)r
rrr�totuple�szTestAddress.totuplecCs|jS)N)r)r
rrr�__str__�szTestAddress.__str__cCs d|j|j|j|jfS)Nz%s: (%s, %s, %s))rrNrGrO)r
rrr�__repr__�szTestAddress.__repr__)r!rHrIrJrrSrTrUrrrrr�s
)"rJ�loggingrKr$Znose.configrZ	nose.utilrrrrrr�	getLoggerr!r'�__all__�path�joinrR�basenamer.�existsZ	op_exists�splitextr3�isabsrP�abspathrQ�objectr	r
rrrrr�<module>s .�