AlkantarClanX12

Your IP : 18.189.170.227


Current Path : /proc/self/root/opt/alt/python35/lib64/python3.5/unittest/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python35/lib64/python3.5/unittest/__pycache__/loader.cpython-35.opt-2.pyc



���]�V�@sjddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZdZej
dej�ZGdd�de	j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejdd�Zdeje
jdd�Zdeje
jdd�ZdS)�N)�fnmatch�)�case�suite�utilTz[_a-z]\w*\.py$cs:eZdZdZ�fdd�Z�fdd�Z�S)�_FailedTestNcs#||_tt|�j|�dS)N)�
_exception�superr�__init__)�selfZmethod_name�	exception)�	__class__��+/opt/alt/python35/lib64/python3.5/loader.pyr
s	z_FailedTest.__init__cs;|�jkr%tt��j|�S�fdd�}|S)Ncs
�j�dS)N)rr)rrr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamer	r�__getattr__)r�namer)r
)rrrsz_FailedTest.__getattr__)�__name__�
__module__�__qualname__rr
rrr)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&srcCs&dtj�f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrrrrrr�_make_failed_load_tests+srcCs"t||�}||f�|fS)N)r)�
methodnamerrr�testrrrr0srcCsXtjt|��dd��}||i}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)rrrr!ZattrsZ	TestClassrrr�_make_skipped_test4s!r&cCs7|j�jd�r#|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r+rrr�_jython_aware_splitext<sr-cs�eZdZdZeej�Zej	Z
dZ�fdd�Zdd�Z
dddd	�Zdd
d�Zddd
�Zdd�Zdddd�Zdd�Zdd�Zdd�Zdd�Zddd�Zddd�Z�S) �
TestLoaderr Ncs,tt|�j�g|_t�|_dS)N)r	r.r
�errors�set�_loading_packages)r)r
rrr
Ls	zTestLoader.__init__cCsht|tj�rtd��|j|�}|rLt|d�rLdg}|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
Os�t|�dksd|kr>tjdt�|jdd�t|�dkrut|�d}tdj|���t|�dkr�t|�d}tdj|���g}xZt|�D]L}t	||�}t
|t�r�t|t
j�r�|j|j|��q�Wt	|dd�}	|j|�}|	dk	r�y|	|||�SWnWtk
r�}
z7t|j|
|j�\}}|jj|�|SWYdd}
~
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�popr4�format�sorted�dir�getattr�
isinstancer$r2rr%�appendr9r�	Exceptionrrr/)
r�moduler:�args�kwsZ	complaint�testsr�objr;�e�
error_case�
error_messagerrr�loadTestsFromModuleas4	!zTestLoader.loadTestsFromModulecCs�|jd�}d\}}|dkr�|dd�}x}|r�y dj|�}t|�}PWq:tk
r�|j�}t||j�\}}|s�|jj|�|SYq:Xq:W|dd�}|}	x�|D]�}
y|	t	|	|
�}}	Wq�t
k
r�}z|t	|	dd�dk	rA|dk	rA|jj|�|St|
||jdtj
�f�\}}|jj|�|SWYdd}~Xq�Xq�Wt|	tj�r�|j|	�St|	t�r�t|	tj�r�|j|	�St|	tj�r[t|t�r[t|tj�r[|d}||�}
tt	|
|�tj�sq|j|
g�Snt|	tj�rq|	St|	�r�|	�}t|tj�r�|St|tj�r�|j|g�Std|	|f��ntd|	��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__rr@rrr/rFrD�AttributeErrorrrrrE�types�
ModuleTyperPr$r2rr%r9�FunctionTyperr3�callabler4)rrrH�partsrNrOZ
parts_copy�module_nameZnext_attributerL�part�parentrM�instr rrr�loadTestsFromName�sl		



!

	zTestLoader.loadTestsFromNamecs)��fdd�|D�}�j|�S)Ncs"g|]}�j|���qSr)ra)�.0r)rHrrr�
<listcomp>�s	z1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesrHZsuitesr)rHrr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCsY||jdd�}tt|t|���}|jrU|jdtj|j��|S)NcSs"|j|�o!tt||��S)N)�
startswithr[rD)Zattrnamer8�prefixrrr�isTestMethod�sz1TestLoader.getTestCaseNames.<locals>.isTestMethod�key)�testMethodPrefix�list�filterrC�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr8rhZtestFnNamesrrrr5�s	zTestLoader.getTestCaseNamesztest*.pycCsd}|dkr-|jdk	r-|j}n|dkrEd}|}tjj|�}|tjkrytjjd|�||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}n�yt	|�Wnt
k
rd}Yn�Xtj|}|jd�d}	y%tjjtjj
|j��}Wntk
r�y
|j}
Wntk
r�d}
YnX|
r@|
jdkr@|
jdk	r|d}x�|jD]j}|r�|j|�r�q�|j|jjdtjj��d|_|j|j||dd��q�Wn<|jtjkrdtd�d�ntdj|��d�YnX|r�|s�|j|	�|_tjj|�ntjj|�|r�t
d	|��|s�t|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_locationsrRrfr�replace�sep�extend�_find_tests�builtin_module_namesr4rA� _get_directory_containing_module�removerkr)r�	start_dirr:Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerKZ
the_moduleZtop_part�specr+rrr�discover�sv	%

	


		zTestLoader.discovercCsstj|}tjj|j�}tjj|�j�jd�r_tjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
rtrxr*r+rsrz�basenamer(rfry)rr]rH�	full_pathrrrr�Xs

!z+TestLoader._get_directory_containing_modulecCs_||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_nameps
z TestLoader._get_module_from_namecCs
t||�S)N)r)rr+r�r:rrr�_match_pathtszTestLoader._match_pathFc
cs |j|�}|dkr`||jkr`|j|||�\}}|dk	rV|V|s`dSttj|��}x�|D]�}tjj||�}	|j|	||�\}}|dk	r�|V|r||j|	�}|jj|�z|j	|	||�EdHWd|jj
|�Xq|WdS)NrQ)r�r1�_find_test_pathrBr*�listdirr+rU�addr��discard)
rr�r:rqrrKZshould_recurse�pathsr+r�rrrr�xs*
zTestLoader._find_testscCs0tjj|�}tjj|�r�tj|�s7dS|j|||�sPd	S|j|�}y|j|�}Wnzt	j
k
r�}zt|||j�dfSWYdd}~Xq,t
||j�\}}	|jj|	�|dfSYq,Xtjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�kr�tjj|�}
ttjj|��}tjj|�}d}t|||
|f��|j|d|�dfSn`tjj|�r(|rtjjtjj|d��rd
Sd}d}|j|�}y|j|�}Wnzt	j
k
r|}zt|||j�dfSWYdd}~Xq,t
||j�\}}	|jj|	�|dfSYq,Xt|dd�}|jj|�z9|j|d|�}|dk	r|dfS|dfSWd|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&rrr/rFrsrDr-�realpathr(ryrrPrvrUr1r�r�)rr�r:rqr�rrHrMrNrOZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr;rK�packagerrrr��sl+	"+
zTestLoader._find_test_path)rrrrj�staticmethodr�
three_way_cmprmrr3rrrr
r9rPrarer5r�r�r�r�r�r�r�rr)r
rr.Bs"	(Nn"r.cCs.t�}||_||_|r*||_|S)N)r.rmrjr)rg�	sortUsingrr|rrr�_makeLoader�s				r�cCst||�j|�S)N)r�r5)r8rgr�rrrr5�sr5r cCst|||�j|�S)N)r�r9)r8rgr�rrrr�	makeSuite�sr�cCst|||�j|�S)N)r�rP)rHrgr�rrrr�
findTestCases�sr�) r*�rertrrXror=r�rrrZ
__unittest�compile�
IGNORECASEr�r%rrrrr&r-�objectr.ZdefaultTestLoaderr�r�r5r3r�r�rrrr�<module>s2��