AlkantarClanX12

Your IP : 3.145.62.36


Current Path : /lib64/python3.6/unittest/__pycache__/
Upload File :
Current File : //lib64/python3.6/unittest/__pycache__/loader.cpython-36.opt-2.pyc

3


 \�V�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZdZej
dej�ZGdd�de	j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejfdd�Zdeje
jfdd�Zdeje
jfdd�ZdS)�N)�fnmatch�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|�j|�dS)N)�
_exception�superr�__init__)�selfZmethod_name�	exception)�	__class__��'/usr/lib64/python3.6/unittest/loader.pyr
sz_FailedTest.__init__cs*|�jkrtt��j|�S�fdd�}|S)Ncs
�j�dS)N)rr)rrr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamer	r�__getattr__)r�namer)r
)rrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rr
r�
__classcell__rr)r
rrsrcCs"d|tj�f}t|t|�||�S)Nz#Failed to import test module: %s
%s)�	traceback�
format_exc�_make_failed_test�ImportError)r�
suiteClass�messagerrr�_make_failed_import_test&srcCsdtj�f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrrrrrr�_make_failed_load_tests+srcCst||�}||f�|fS)N)r)�
methodnamerrr�testrrrr0s
rcCs<tjt|��dd��}||i}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r rrr"ZattrsZ	TestClassrrr�_make_skipped_test4sr'cCs*|j�jd�r|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r,rrr�_jython_aware_splitext<sr.cs�eZdZdZeej�Zej	Z
dZ�fdd�Zdd�Z
dd�dd	�Zd d
d�Zd!dd
�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zd#dd�Zd$dd�Z�ZS)%�
TestLoaderr!Ncs tt|�j�g|_t�|_dS)N)r	r/r
�errors�set�_loading_packages)r)r
rrr
LszTestLoader.__init__cCsHt|tj�rtd��|j|�}|r4t|d�r4dg}|jt||��}|S)NzYTest cases should not be derived from TestSuite. Maybe you meant to derive from TestCase?ZrunTest)�
issubclassr�	TestSuite�	TypeError�getTestCaseNames�hasattrr�map)r�
testCaseClassZ
testCaseNamesZloaded_suiterrr�loadTestsFromTestCaseSs
z TestLoader.loadTestsFromTestCase)�patternc
Os2t|�dksd|kr,tjdt�|jdd�t|�dkrRt|�d}tdj|���t|�dkrxt|�d}tdj|���g}x@t|�D]4}t	||�}t
|t�r�t|t
j�r�|j|j|��q�Wt	|dd�}	|j|�}|	dk	�r.y|	|||�Stk
�r,}
z$t|j|
|j�\}}|jj|�|Sd}
~
XnX|S)NrZuse_load_testsz(use_load_tests is deprecated and ignoredrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr5�format�sorted�dir�getattr�
isinstancer%r3rr&�appendr:r�	Exceptionrrr0)
r�moduler;�argsZkwsZ	complaint�testsr�objr<�e�
error_case�
error_messagerrr�loadTestsFromModuleas4


zTestLoader.loadTestsFromModulecCs>|jd�}d\}}|dkr�|dd�}xb|r�ydj|�}t|�}PWq(tk
r�|j�}t||j�\}}|s�|jj|�|SYq(Xq(W|dd�}|}	x�|D]�}
y|	t	|	|
�}}	Wq�t
k
�r2}z\t	|	dd�dk	r�|dk	r�|jj|�|St|
||jdtj
�f�\}}|jj|�|SWYdd}~Xq�Xq�Wt|	tj��rP|j|	�St|	t��rtt|	tj��rt|j|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|j|
g�Snt|	tj��r�|	St|	��r.|	�}t|tj��r|St|tj��r|j|g�Std|	|f��ntd|	��dS)	N�.r�__path__zFailed to access attribute:
%sz"calling %s returned %s, not a testz$don't know how to make test from: %s)NN���)�split�join�
__import__rrArrr0rGrE�AttributeErrorrrrrF�types�
ModuleTyperPr%r3rr&r:�FunctionTyperr4�callabler5)rrrI�partsrNrOZ
parts_copy�module_nameZnext_attributerL�part�parentrMZinstr!rrr�loadTestsFromName�sl	





zTestLoader.loadTestsFromNamecs��fdd�|D�}�j|�S)Ncsg|]}�j|���qSr)r`)�.0r)rIrrr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesrIZsuitesr)rIrr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCs@||jfdd�}tt|t|���}|jr<|jtj|j�d�|S)NcSs|j|�ott||��S)N)�
startswithr[rE)Zattrnamer9�prefixrrr�isTestMethod�s
z1TestLoader.getTestCaseNames.<locals>.isTestMethod)�key)�testMethodPrefix�list�filterrD�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr9rgZtestFnNamesrrrr6�szTestLoader.getTestCaseNames�test*.pycCsRd}|dkr|jdk	r|j}n|dkr.d}|}tjj|�}|tjkrRtjjd|�||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}�nxyt	|�Wnt
k
r�d}Y�nRXtj|}|jd�d}	ytjjtjj
|j��}Wn�tk
�r�y
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}x�|jD]T}|�r�|j|��r��qd|j|jjdtjj��d|_|j|j||dd���qdWn*|jtjk�r�td�d�ntdj|��d�YnX|�r |�s|j|	�|_tjj|�ntjj|�|�r2t
d	|��|�sHt|j||��}|j |�S)
NFTrz__init__.pyrQ)�	namespacez2Can not use builtin modules as dotted module namesz$don't know how to discover from {!r}z%Start directory is not importable: %r)!�_top_level_dirr+r,�abspath�sys�insert�isdir�isfilerUrVr�modulesrT�dirname�__file__rW�__spec__�loader�submodule_search_locationsrRrer�replace�sep�extend�_find_tests�builtin_module_namesr5rB� _get_directory_containing_module�removerjr)r�	start_dirr;Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerKZ
the_moduleZtop_part�specr,rrr�discover�sv





zTestLoader.discovercCsRtj|}tjj|j�}tjj|�j�jd�rBtjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
rtrxr+r,rsrz�basenamer)rery)rr]rI�	full_pathrrrr�Xs

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttjj|��}tjj||j�}|jtjjd�}|S)NrQ)rrr.r+r,�normpath�relpathr~r)rr,Z_relpathrrrr�_get_name_from_pathds
zTestLoader._get_name_from_pathcCst|�tj|S)N)rVrtrx)rrrrr�_get_module_from_namepsz TestLoader._get_module_from_namecCs
t||�S)N)r)rr,r�r;rrr�_match_pathtszTestLoader._match_pathFc
cs�|j|�}|dkrD||jkrD|j|||�\}}|dk	r<|V|sDdSttj|��}x||D]t}tjj||�}	|j|	||�\}}|dk	r�|V|rX|j|	�}|jj|�z|j	|	||�EdHWd|jj
|�XqXWdS)NrQ)r�r2�_find_test_pathrCr+�listdirr,rU�addr��discard)
rr�r;rqrrKZshould_recurse�pathsr,r�rrrr�xs*


zTestLoader._find_testscCsPtjj|�}tjj|��rFtj|�s(dS|j|||�s:d	S|j|�}y|j|�}WnXt	j
k
r�}zt|||j�dfSd}~Xn�t
||j�\}}	|jj|	�|dfStjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�k�r0tjj|�}
ttjj|��}tjj|�}d}t|||
|f��|j||d�dfS�ntjj|��rH|�rztjjtjj|d���rzd
Sd}d}|j|�}y|j|�}WnZt	j
k
�r�}zt|||j�dfSd}~Xnzt
||j�\}}	|jj|	�|dfSt|dd�}|jj|�z(|j||d�}|dk	�r0|dfS|dfS|jj|�XndSdS)NFrzzW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?)r;z__init__.pyr<T)NF)NF)NF)NF)r+r,r�rw�VALID_MODULE_NAME�matchr�r�r�rZSkipTestr'rrr0rGrsrEr.�realpathr)ryrrPrvrUr2r�r�)rr�r;rqr�rrIrMrNrOZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr<rK�packagerrrr��sl



zTestLoader._find_test_path)N)N)rpN)F)F)rrrri�staticmethodr�
three_way_cmprlrr4rrrr
r:rPr`rdr6r�r�r�r�r�r�r�rrr)r
rr/Bs"
(
N

n
"r/cCs t�}||_||_|r||_|S)N)r/rlrir)rf�	sortUsingrr|rrr�_makeLoader�sr�cCst||�j|�S)N)r�r6)r9rfr�rrrr6�sr6r!cCst|||�j|�S)N)r�r:)r9rfr�rrrr�	makeSuite�sr�cCst|||�j|�S)N)r�rP)rIrfr�rrrr�
findTestCases�sr�)N) r+�rertrrXrnr>r�rrrZ
__unittest�compile�
IGNORECASEr�r&rrrrr'r.�objectr/ZdefaultTestLoaderr�r�r6r4r�r�rrrr�<module>s6'