AlkantarClanX12

Your IP : 18.188.219.131


Current Path : /opt/alt/python39/lib64/python3.9/unittest/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/unittest/__pycache__/loader.cpython-39.opt-2.pyc

a

R�f�X�@sddlZddlZddlZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZdZ
e�dej�ZGdd�de
j�Zd	d
�Zdd�Zd
d�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejdfdd�Zdejejfdd�Zdejejfdd�Z dS)�N)�fnmatch�fnmatchcase�)�case�suite�utilTz[_a-z]\w*\.py$cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�_FailedTestNcs||_tt|��|�dS�N)�
_exception�superr�__init__)�selfZmethod_name�	exception��	__class__��4/opt/alt/python39/lib64/python3.9/unittest/loader.pyrsz_FailedTest.__init__cs*|�jkrtt���|�S�fdd�}|S)Ncs
�j�dSr	)r
r�r
rr�testFailure!sz,_FailedTest.__getattr__.<locals>.testFailure)�_testMethodNamerr�__getattr__)r
�namerrrrrs
z_FailedTest.__getattr__)�__name__�
__module__�__qualname__rrr�
__classcell__rrrrrsrcCs"d|t��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&s�r"cCsdt��f}t||||�S)NzFailed to call load_tests:
%s)rrr)rrr r!rrr�_make_failed_load_tests+s�r#cCst||�}||f�|fSr	)r)�
methodnamerr r!�testrrrr0s
rcCs<t�t|��dd��}||i}tdtjf|�}|||�f�S)NcSsdSr	rrrrr�testSkipped5sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)r$rr r&�attrsZ	TestClassrrr�_make_skipped_test4s

r,cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r0rrr�_jython_aware_splitext<sr2cs�eZdZdZeej�ZdZe	j
ZdZ�fdd�Z
dd�Zdd�dd	�Zd d
d�Zd!dd
�Zdd�Zd"dd�Zdd�Zdd�Zdd�Zdd�Zd#dd�Zd$dd�Z�ZS)%�
TestLoaderr%Ncs tt|���g|_t�|_dSr	)rr3r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|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�loadTestsFromTestCaseTs
z TestLoader.loadTestsFromTestCase��patternc

Os8t|�dksd|vr,t�dt�|�dd�t|�dkrRt|�d}td�|���t|�dkrxt|�d}td�|���g}t|�D]4}t	||�}t
|t�r�t|t
j�r�|�|�|��q�t	|dd�}	|�|�}|	du�r4z|	|||�WSt�y2}
z0t|j|
|j�\}}|j�|�|WYd}
~
Sd}
~
00|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�popr9�format�sorted�dir�getattr�
isinstancer)r7rr*�appendr>r �	Exceptionr#rr4)
r
�moduler@�argsZkwsZ	complaint�testsr�objrA�e�
error_case�
error_messagerrr�loadTestsFromModulebs8�



�zTestLoader.loadTestsFromModulecCs`|�d�}d\}}|dur�|dd�}|r�zd�|�}t|�}Wq�Wq&ty�|��}t||j�\}}|s�|j�|�|YSYq&0q&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
�yV}z�t	|	dd�du�r|du�r|j�|�|WYd}~St|
||jdt�
�f�\}}|j�|�|WYd}~SWYd}~q�d}~00q�t|	tj��rr|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s|�|
g�Snt|	tj��r|	St|	��rP|	�}t|tj��r$|St|tj��r>|�|g�Std|	|f��ntd|	��dS)	N�.)NNr�__path__zFailed to access attribute:
%s���z"calling %s returned %s, not a testz$don't know how to make test from: %s)�split�join�
__import__rrFr"r r4rLrJ�AttributeErrorrrrrK�types�
ModuleTyperUr)r7rr*r>�FunctionTyperr8�callabler9)r
rrN�partsrSrTZ
parts_copy�module_nameZnext_attributerQ�part�parentrR�instr%rrr�loadTestsFromName�sz	

����,

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)Ncsg|]}��|���qSr)rf)�.0r�rNr
rr�
<listcomp>��z1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrNZsuitesrrhr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)NcsZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdupXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rgr@�ZfullNamerr�	<genexpr>�rjzKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrJr`rr�testNamePatterns�any)�attrnameZtestFunc�r
r=rmr�shouldIncludeMethod�s

�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrI�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r=ruZtestFnNamesrrtrr:�s
zTestLoader.getTestCaseNames�test*.pycCsDd}|dur|jdur|j}n|dur.d}|}tj�|�}|tjvrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�njzt	|�Wnt
y�d}Y�nF0tj|}|�d�d}	ztj�tj�
|j��}Wn�t�y�z
|j}
Wnt�y2d}
Yn0|
�r�|
jdu�r�|
jdu�r�d}|jD]P}|�sv|�|��sv�q\|�|j�dtjj��d|_|�|j||dd���q\n*|jtjv�r�td�d�ntd�|��d�Yn0|�r|�s|�|	�|_tj�|�ntj�|�|�r$t
d	|��|�s:t|�||��}|� |�S)
NFTr�__init__.pyrV)�	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/r0�abspath�sys�insert�isdir�isfilerZr[r�modulesrY�dirname�__file__r\�__spec__�loader�submodule_search_locationsrWror�replace�sep�extend�_find_tests�builtin_module_namesr9rG� _get_directory_containing_module�removerwr )r
�	start_dirr@Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerPZ
the_moduleZtop_part�specr0rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr~)
r�r�r/r0r�r��basenamer-ror�)r
rbrN�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsB||jkrdSttj�|��}tj�||j�}|�tjjd�}|S�NrV)r�r2r/r0�normpath�relpathr�r�)r
r0Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)r[r�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r0r�r@rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jvrD|�|||�\}}|dur<|V|sDdStt�|��}|D]�}tj�||�}	|�|	||�\}}|dur�|V|rV|�|	�}|j�|�z$|�	|	||�EdHW|j�
|�qV|j�
|�0qVdSr�)r�r6�_find_test_pathrHr/�listdirr0rZ�addr��discard)
r
r�r@rrrPZshould_recurse�pathsr0r�rrrr��s.
��
zTestLoader._find_testsc
Cs�tj�|�}tj�|��rTt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnft	j
y�}zt|||j�dfWYd}~Sd}~0t
||j�\}}	|j�|	�|dfYS0tj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r>tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�n,tj�|��r||�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnht	j
�y�}zt|||j�dfWYd}~Sd}~0t
||j�\}}	|j�|	�|dfYS0t|dd�}|j�|�zD|j||d�}|du�rV|dfW|j�|�S|dfW|j�|�S|j�|�0ndSdS)	N)NFFr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r?r~rAT)r/r0r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr,r r"r4rLr�rJr2�realpathr-r�rrUr�rZr6r�r�)r
r�r@rr�rrNrRrSrTZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgrArP�packagerrrr��s�

&
�
�
�
�
���
&
�
��zTestLoader._find_test_path)N)N)r}N)F)F)rrrrp�staticmethodr�
three_way_cmpryrqrr8r r�rr>rUrfrlr:r�r�r�r�r�r�r�rrrrrr3Bs$
(
N

n
"r3cCs&t�}||_||_||_|r"||_|Sr	)r3ryrprqr )�prefix�	sortUsingr rqr�rrr�_makeLoader�sr�cCst|||d��|�S)N)rq)r�r:)r=r�r�rqrrrr:�sr:r%cCst|||��|�Sr	)r�r>)r=r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rU)rNr�r�r rrr�
findTestCasess�r�)NN)!r/�rer�rr]r{rCrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr,r2�objectr3ZdefaultTestLoaderr�r�r:r8r�r�rrrr�<module>s:/
	�
�