%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core20/2318/lib/python3.8/unittest/__pycache__/
Upload File :
Create Path :
Current File : //snap/core20/2318/lib/python3.8/unittest/__pycache__/loader.cpython-38.pyc

U

k�]e�X�@sdZddlZddlZddlZddlZddlZddlZddlZddlmZm	Z	ddl
mZmZm
Z
dZe�dej�ZGdd	�d	ej�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Ze
jdfdd�Zde
jejfdd�Z de
jejfdd�Z!dS) zLoading unittests.�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__��%/usr/lib/python3.8/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&ZattrsZ	TestClassrrr�_make_skipped_test4s

r+cCs*|���d�r|dd�Stj�|�dS)Nz	$py.classi����r)�lower�endswith�os�path�splitext)r/rrr�_jython_aware_splitext<sr1cs�eZdZdZdZeej�ZdZ	e
jZdZ
�fdd�Zdd�Zdd�d	d
�Zd!dd�Zd"d
d�Zdd�Zd#dd�Zdd�Zdd�Zdd�Zdd�Zd$dd�Zd%dd �Z�ZS)&�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r%Ncs tt|���g|_t�|_dSr	)rr2r�errors�set�_loading_packagesrrrrrMszTestLoader.__init__cCsFt|tj�rtd��|�|�}|s2t|d�r2dg}|�t||��}|S)z;Return a suite of all test cases contained in testCaseClasszYTest 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

Os:t|�dksd|kr,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�}	|�|�}|	dk	�r6z|	|||�WStk
�r4}
z,t|j|
|j�\}}|j�|�|WY�Sd}
~
XYnX|S)	z>Return a suite of all test cases contained in the given modulerZuse_load_testsz(use_load_tests is deprecated and ignoredNrzCloadTestsFromModule() takes 1 positional argument but {} were givenz=loadTestsFromModule() got an unexpected keyword argument '{}'�
load_tests)�len�warnings�warn�DeprecationWarning�popr8�format�sorted�dir�getattr�
isinstancer)r6rr*�appendr=r �	Exceptionr#rr3)
r
�moduler?�argsZkwsZ	complaint�testsr�objr@�e�
error_case�
error_messagerrr�loadTestsFromModulebs<�


�zTestLoader.loadTestsFromModulecCsX|�d�}d\}}|dkr�|dd�}|r�zd�|�}t|�}Wq�Wq&tk
r�|��}t||j�\}}|s�|j�|�|YSYq&Xq&|dd�}|}	|D]�}
z|	t	|	|
�}}	Wq�t
k
�rN}zvt	|	dd�dk	�r|dk	�r|j�|�|WY�DSt|
||jdt�
�f�\}}|j�|�|WY�
SW5d}~XYq�Xq�t|	tj��rj|�|	�St|	t��r�t|	tj��r�|�|	�St|	tj��r�t|t��r�t|tj��r�|d}||�}
tt	|
|�tj��s�|�|
g�Snt|	tj��r�|	St|	��rH|	�}t|tj��r|St|tj��r6|�|g�Std|	|f��ntd	|	��dS)
aSReturn a suite of all test cases given a string specifier.

        The name may resolve either to a module, a test case class, a
        test method within a test case class, or a callable object which
        returns a TestCase or TestSuite instance.

        The method optionally resolves the names relative to a given module.
        �.)NNNr�__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__rrEr"r r3rKrI�AttributeErrorrrrrJ�types�
ModuleTyperTr)r6rr*r=�FunctionTyperr7�callabler8)r
rrM�partsrRrSZ
parts_copy�module_nameZnext_attributerP�part�parentrQ�instr%rrr�loadTestsFromName�s�	

����$

�
�
�zTestLoader.loadTestsFromNamecs��fdd�|D�}��|�S)z�Return a suite of all test cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        csg|]}��|���qSr)re)�.0r�rMr
rr�
<listcomp>�sz1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r )r
�namesrMZsuitesrrgr�loadTestsFromNames�szTestLoader.loadTestsFromNamescs>��fdd�}tt|t����}�jr:|jt��j�d�|S)zLReturn a sorted sequence of method names found within testCaseClass
        csZ|��j�sdSt�|�}t|�s&dSd�j�j|f��jdkpXt�fdd��jD��S)NFz%s.%s.%sc3s|]}t�|�VqdSr	)r)rfr?�ZfullNamerr�	<genexpr>�szKTestLoader.getTestCaseNames.<locals>.shouldIncludeMethod.<locals>.<genexpr>)�
startswith�testMethodPrefixrIr_rr�testNamePatterns�any)�attrnameZtestFunc�r
r<rkr�shouldIncludeMethod�s
�
�z8TestLoader.getTestCaseNames.<locals>.shouldIncludeMethod)�key)�list�filterrH�sortTestMethodsUsing�sort�	functools�
cmp_to_key)r
r<rsZtestFnNamesrrrrr9�s
zTestLoader.getTestCaseNames�test*.pycCsJd}|dkr|jdk	r|j}n|dkr.d}|}tj�|�}|tjkrRtj�d|�||_d}d}g}tj�tj�|��r�tj�|�}||kr�tj�tj�|d��}�npzt	|�Wnt
k
r�d}Y�nJXtj|}|�d�d}	ztj�tj�
|j��}Wn�tk
�r�z
|j}
Wntk
�r8d}
YnX|
�r�|
jdk�r�|
jdk	�r�d}|jD]P}|�s||�|��s|�qb|�|j�dtjj��d|_|�|j||dd���qbn*|jtjk�r�td�d�ntd	�|��d�YnX|�r|�s|�|	�|_tj�|�ntj�|�|�r*t
d
|��|�s@t|�||��}|� |�S)a%Find and return all test modules from the specified start
        directory, recursing into subdirectories to find them and return all
        tests found within them. Only test files that match the pattern will
        be loaded. (Using shell style pattern matching.)

        All test modules must be importable from the top level of the project.
        If the start directory is not the top level directory then the top
        level directory must be specified separately.

        If a test package name (directory with '__init__.py') matches the
        pattern then the package will be checked for a 'load_tests' function. If
        this exists then it will be called with (loader, tests, pattern) unless
        the package has already had load_tests called from the same discovery
        invocation, in which case the package module object is not scanned for
        tests - this ensures that when a package uses discover to further
        discover child tests that infinite recursion does not happen.

        If load_tests exists then discovery does *not* recurse into the package,
        load_tests is responsible for loading all tests in the package.

        The pattern is deliberately not stored as a loader attribute so that
        packages can continue discovery themselves. top_level_dir is stored so
        load_tests does not need to pass this argument in to loader.discover().

        Paths are sorted before being imported to ensure reproducible execution
        order even on filesystems with non-alphabetical ordering like ext3/4.
        FNTr�__init__.pyrU)�	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�isfilerYrZr�modulesrX�dirname�__file__r[�__spec__�loader�submodule_search_locationsrVrmr�replace�sep�extend�_find_tests�builtin_module_namesr8rF� _get_directory_containing_module�removerur )r
�	start_dirr?Z
top_level_dirZset_implicit_topZis_not_importable�is_namespacerOZ
the_moduleZtop_part�specr/rrr�discover�s�

�


�
���
������zTestLoader.discovercCsRtj|}tj�|j�}tj�|����d�rBtj�	tj�	|��Stj�	|�SdS)Nr|)
r�r�r.r/rr��basenamer,rmr�)r
rarM�	full_pathrrrr�`s

z+TestLoader._get_directory_containing_modulecCsh||jkrdSttj�|��}tj�||j�}tj�|�rBtd��|�d�rTtd��|�	tjj
d�}|S)NrUzPath must be within the projectz..)r~r1r.r/�normpath�relpath�isabs�AssertionErrorrmr�r�)r
r/Z_relpathrrrr�_get_name_from_pathls
zTestLoader._get_name_from_pathcCst|�tj|Sr	)rZr�r�)r
rrrr�_get_module_from_namexsz TestLoader._get_module_from_namecCs
t||�Sr	)r)r
r/r�r?rrr�_match_path|szTestLoader._match_pathFc

cs�|�|�}|dkrD||jkrD|�|||�\}}|dk	r<|V|sDdStt�|��}|D]t}tj�||�}	|�|	||�\}}|dk	r�|V|rV|�|	�}|j�|�z|�
|	||�EdHW5|j�	|�XqVdS)z/Used by discovery. Yields test suites it loads.rUN)r�r5�_find_test_pathrGr.�listdirr/rY�add�discardr�)
r
r�r?r}rrOZshould_recurse�pathsr/r�rrrr��s6
��
zTestLoader._find_testsc
Csttj�|�}tj�|��rVt�|�s(dS|�|||�s:dS|�|�}z|�|�}Wnht	j
k
r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXtj�t|d|��}
ttj�|
��}ttj�|��}|��|��k�r@tj�|�}
ttj�|��}tj�|�}d}t|||
|f��|j||d�dfS�ntj�|��rl|�s�tj�tj�|d���s�dSd}d}|�|�}z|�|�}Wnjt	j
k
�r�}zt|||j�dfWY�Sd}~XYn�t
||j�\}}	|j�|	�|dfYSXt|dd�}|j�|�z0|j||d�}|dk	�rP|dfW�S|d	fW�S|j�|�XndSdS)
z�Used by discovery.

        Loads tests from a single file, or a directories' __init__.py when
        passed the directory.

        Returns a tuple (None_or_tests_from_file, should_recurse).
        )NFFNr�zW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?r>r|r@T)r.r/r�r��VALID_MODULE_NAME�matchr�r�r�rZSkipTestr+r r"r3rKrrIr1�realpathr,r�rrTr�rYr5r�r�)r
r�r?r}r�rrMrQrRrSZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr@rO�packagerrrr��s|

&
�
�
�
�
���
&
�
zTestLoader._find_test_path)N)N)r{N)F)F)rrr�__doc__rn�staticmethodr�
three_way_cmprwrorr7r r~rr=rTrerjr9r�r�r�r�r�r�r�rrrrrr2Bs&
(
N

n
"r2cCs&t�}||_||_||_|r"||_|Sr	)r2rwrnror )�prefix�	sortUsingr ror�rrr�_makeLoader�sr�cCst|||d��|�S)N)ro)r�r9)r<r�r�rorrrr9�sr9r%cCst|||��|�Sr	)r�r=)r<r�r�r rrr�	makeSuite�s�r�cCst|||��|�Sr	)r�rT)rMr�r�r rrr�
findTestCasess�r�)NN)"r�r.�rer�rr\ryrBrr�rrrZ
__unittest�compile�
IGNORECASEr�r*rr"r#rr+r1�objectr2ZdefaultTestLoaderr�r�r9r7r�r�rrrr�<module>s</
	�
�

Zerion Mini Shell 1.0