ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/unittest/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/unittest/__pycache__/loader.cpython-34.pyc

�
j f�@�@sddZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZdZej
dej�ZGdd	�d	e	j�Zd
d�Zdd
�Zdd�Zdd�Zdd�ZGdd�de�Ze�Zddd�Zejdd�Zdeje
jdd�Zdeje
jdd�ZdS)zLoading unittests.�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__��4/opt/alt/python34/lib64/python3.4/unittest/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%srcCst|||�S)N)r)rrrrrr�_make_failed_load_tests)srcCst||�}||f�S)N)r)�
methodnamerr�testrrrr,srcCsYtjt|��dd��}i||6}tdtjf|�}|||�f�S)NcSsdS)Nr)rrrr�testSkipped1sz'_make_skipped_test.<locals>.testSkippedZ
ModuleSkipped)r�skip�str�type�TestCase)rrrr!�attrsZ	TestClassrrr�_make_skipped_test0s!
r'cCs7|j�jd�r#|dd�Stjj|�dS)Nz	$py.class�	ri����)�lower�endswith�os�path�splitext)r,rrr�_jython_aware_splitext8sr.c@s�eZdZdZdZeej�Ze	j
ZdZdd�Z
ddd�Zdd	d
�Zddd�Zd
d�Zdddd�Zdd�Zdd�Zdd�Zdd�Zddd�ZdS)�
TestLoaderz�
    This class is responsible for loading tests according to various criteria
    and returning them wrapped in a TestSuite
    r NcCsnt|tj�r!td��n|j|�}|rRt|d�rRdg}n|jt||��}|S)z<Return a suite of all tests 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�loadTestsFromTestCaseHsz TestLoader.loadTestsFromTestCaseTcCs�g}x]t|�D]O}t||�}t|t�rt|tj�r|j|j|��qqWt|dd�}|j	|�}|r�|dk	r�y|||d�SWq�t
k
r�}zt|j||j	�SWYdd}~Xq�Xn|S)z?Return a suite of all tests cases contained in the given module�
load_testsN)
�dir�getattr�
isinstancer$r0rr%�appendr7r�	Exceptionrr)r�module�use_load_tests�testsr�objr8�errr�loadTestsFromModuleTs! zTestLoader.loadTestsFromModulec
Cs|jd�}|dkr�|dd�}xL|ryytdj|��}PWq.tk
ru|d=|sq�nYq.Xq.W|dd�}n|}x$|D]}|t||�}}q�Wt|tj�r�|j|�St|t	�rt
|tj�r|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��ntd|��dS)aTReturn a suite of all tests 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.
        �.Nrz"calling %s returned %s, not a testz$don't know how to make test from: %s���rE)�split�
__import__�joinrr:r;�types�
ModuleTyperCr$r0rr%r7�FunctionTyperrr1�callabler2)
rrr>�partsZ
parts_copyrA�part�parentZinstr rrr�loadTestsFromNamefsJ		


!

	zTestLoader.loadTestsFromNamecs)��fdd�|D�}�j|�S)z�Return a suite of all tests cases found using the given sequence
        of string specifiers. See 'loadTestsFromName()'.
        cs"g|]}�j|���qSr)rP)�.0r)r>rrr�
<listcomp>�s	z1TestLoader.loadTestsFromNames.<locals>.<listcomp>)r)r�namesr>Zsuitesr)r>rr�loadTestsFromNames�szTestLoader.loadTestsFromNamescCs\||jdd�}tt|t|���}|jrX|jdtj|j��n|S)zLReturn a sorted sequence of method names found within testCaseClass
        cSs"|j|�o!tt||��S)N)�
startswithrLr:)Zattrnamer6�prefixrrr�isTestMethod�sz1TestLoader.getTestCaseNames.<locals>.isTestMethod�key)�testMethodPrefix�list�filterr9�sortTestMethodsUsing�sort�	functools�
cmp_to_key)rr6rWZtestFnNamesrrrr3�s	zTestLoader.getTestCaseNamesztest*.pycCsd}|dkr-|jdk	r-|j}n|dkrHd}|}ntjj|�}|tjkrtjjd|�n||_d}d}g}tjjtjj|��r�tjj|�}||kr�tjjtjj|d��}q�n�yt	|�Wnt
k
r&d}Yn�Xtj|}|jd�d}	y%tjjtjj
|j��}Wn!tk
r�y
|j}
Wntk
r�d}
YnX|
rO|
jdkrO|
jdk	r�d}x{|jD]m}|r�|j|�r�q�n|j|jjdtjj��d|_|j|j||dd��q�Wq�n<|jtjkrstd�d�ntd	j|��d�YnX|r�|s�|j|	�|_tjj|�q�tjj|�n|r�t
d
|��n|st|j||��}n|j |�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.

        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.
        FNTrz__init__.pyrD�	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�isfilerHrGr�modulesrF�dirname�__file__�AttributeError�__spec__�loader�submodule_search_locations�__path__rUr�replace�sep�extend�_find_tests�builtin_module_namesr2�format� _get_directory_containing_module�removerZr)r�	start_dir�patternZ
top_level_dirZset_implicit_topZis_not_importable�is_namespacer@Z
the_moduleZtop_part�specr,rrr�discover�sv		(

	


		zTestLoader.discovercCsstj|}tjj|j�}tjj|�j�jd�r_tjj	tjj	|��Stjj	|�SdS)Nz__init__.py)
rcrgr+r,rbri�basenamer)rUrh)rZmodule_namer>�	full_pathrrrrus

!z+TestLoader._get_directory_containing_modulecCs�ttjj|��}tjj||j�}tjj|�sOtd��|jd�sktd��|j	tjj
d�}|S)NzPath must be within the projectz..rD)r.r+r,�normpath�relpathra�isabs�AssertionErrorrUrorp)rr,Z_relpathrrrr�_get_name_from_path"szTestLoader._get_name_from_pathcCst|�tj|S)N)rGrcrg)rrrrr�_get_module_from_name,s
z TestLoader._get_module_from_namecCs
t||�S)N)r)rr,r}rxrrr�_match_path0szTestLoader._match_pathFccsttj|��}x�|D]�}tjj||�}tjj|�r�tj|�s^qn|j|||�syqn|j	|�}y|j
|�}WnTtjk
r�}	zt
||	|j�VWYdd}	~	Xqt||j�VYqXtjjt|d|��}
ttjj|
��}ttjj|��}|j�|j�kr�tjj|�}
ttjj|��}tjj|�}d}t|||
|f��n|j|�Vqtjj|�r|rtjjtjj|d��rqnd}d}t||�rk|j	|�}|j
|�}t|dd�}|j|dd�}n|dkr�|dk	r�|Vn|j||d|�DdHqy||||�VWqtk
r�}	zt|j|	|j�VWYdd}	~	XqXqqWdS)	z/Used by discovery. Yields test suites it loads.NrizW%r module incorrectly imported from %r. Expected %r. Is this module globally installed?z__init__.pyr8r?Fr`)�sortedr+�listdirr,rHrf�VALID_MODULE_NAME�matchr�r�r�rZSkipTestr'rrrbr:r.�realpathr)rhr|rrCrerrrr=rr)rrwrxr`�pathsr,r}rr>rBZmod_filer�Zfullpath_noextZ
module_dirZmod_nameZexpected_dir�msgr8r@�packagerrrrr4s\
&"zTestLoader._find_tests)rrr�__doc__rY�staticmethodr�
three_way_cmpr\rr1rrar7rCrPrTr3r{rur�r�r�rrrrrrr/>s 	3j
r/cCs1t�}||_||_|r-||_n|S)N)r/r\rYr)rV�	sortUsingrrlrrr�_makeLoaderss			r�cCst||�j|�S)N)r�r3)r6rVr�rrrr3{sr3r cCst|||�j|�S)N)r�r7)r6rVr�rrrr�	makeSuite~sr�cCst|||�j|�S)N)r�rC)r>rVr�rrrr�
findTestCases�sr�) r�r+�rercrrIr^r�rrrZ
__unittest�compile�
IGNORECASEr�r%rrrrr'r.�objectr/ZdefaultTestLoaderr�r�r3r1r�r�rrrr�<module>s2�3			

Zerion Mini Shell 1.0