AlkantarClanX12

Your IP : 3.135.206.25


Current Path : /opt/alt/python35/lib64/python3.5/unittest/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/unittest/__pycache__/suite.cpython-35.opt-1.pyc



��Yf�(�@s�dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCs#t||dd��}|�dS)NcSsdS)N�rrr�3/opt/alt/python35/lib64/python3.5/unittest/suite.py�<lambda>sz!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssr
c@s�eZdZdZdZfdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TcCs#g|_d|_|j|�dS)Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__s		zBaseTestSuite.__init__cCs dtj|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list)rrrr�__repr__szBaseTestSuite.__repr__cCs,t||j�stSt|�t|�kS)N)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�S)N)�iterr)rrrr�__iter__"szBaseTestSuite.__iter__cCs4|j}x$|D]}|r||j�7}qW|S)N)r�countTestCases)rZcases�testrrrr%s
	
zBaseTestSuite.countTestCasescCsnt|�s'tdjt|����t|t�rZt|tjt	f�rZtd��|j
j|�dS)Nz{} is not callablezNTestCases and TestSuites must be instantiated before passing them to addTest())�callable�	TypeError�format�reprr�type�
issubclassrZTestCaserr�append)rr rrr�addTest,szBaseTestSuite.addTestcCs=t|t�rtd��x|D]}|j|�q"WdS)Nz0tests must be an iterable of tests, not a string)r�strr"r()rrr rrrr6s
zBaseTestSuite.addTestscCsKxDt|�D]6\}}|jr#P||�|jr
|j|�q
W|S)N)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr rrr�run<s	
	zBaseTestSuite.runcCs[y|j|}Wntk
r%Yn2Xt|d�rJ|j|j�7_d|j|<dS)z2Stop holding a reference to the TestCase at index.rN)rr"�hasattrrr)rr/r rrrr-Es
z BaseTestSuite._removeTestAtIndexcOs|j||�S)N)r0)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCsx|D]}|j�qWdS)z7Run the tests without collecting errors in a TestResultN)�debug)rr rrrr5Vs
zBaseTestSuite.debugN)�__name__�
__module__�__qualname__�__doc__r,rrrrrr(rr0r-r4r5rrrrrs
	rc@syeZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)ra�A test suite is a composite test consisting of a number of TestCases.

    For use, create an instance of TestSuite, then add test case instances.
    When all tests have been added, the suite can be passed to a test
    runner, such as TextTestRunner. It will run the individual test cases
    in the order in which they were added, aggregating the results. When
    subclassing, do not forget to call the base class constructor.
    FcCs'd}t|dd�dkr+d|_}x�t|�D]�\}}|jrNPt|�r�|j||�|j||�|j||�|j|_	t|jdd�s8t|dd�r�q8|s�||�n
|j
�|jr8|j|�q8W|r#|jd|�|j
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)r	r:r*r+�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr5r,r-�_handleModuleTearDown)rr.r5ZtopLevelr/r rrrr0fs0
	

	
	z
TestSuite.runcCst�}|j|d�dS)z7Run the tests without collecting errors in a TestResultTN)�_DebugResultr0)rr5rrrr5�s	zTestSuite.debugc	 Cs.t|dd�}|j}||kr+dS|jr8dSt|dd�rNdSy
d|_Wntk
roYnXt|dd�}|dk	r*t|d�z~y|�Wnltk
r}zLt|t�r��d|_t	j
|�}d|}|j|||�WYdd}~XnXWdt|d�XdS)	NrA�__unittest_skip__F�
setUpClass�_setupStdoutTzsetUpClass (%s)�_restoreStdout)r	rr<r;r"r
�	ExceptionrrCrr�_addClassOrModuleLevelException)	rr r.�
previousClass�currentClassrE�e�	className�	errorNamerrrr@�s2		


	
*zTestSuite._handleClassSetUpcCs1d}t|dd�}|dk	r-|j}|S)NrA)r	r7)rr.�previousModulerJrrr�_get_previous_module�s
	zTestSuite._get_previous_modulec	 Cs|j|�}|jj}||kr+dS|j|�d|_ytj|}Wntk
rjdSYnXt|dd�}|dk	rt	|d�zoy|�Wn]t
k
r}z=t|t�r��d|_d|}|j
|||�WYdd}~XnXWdt	|d�XdS)NF�setUpModulerFTzsetUpModule (%s)rG)rPrr7rBr<�sys�modules�KeyErrorr	r
rHrrCrI)	rr r.rOZ
currentModule�modulerQrLrNrrrr?�s,
	
	
	
*zTestSuite._handleModuleFixturecCslt|�}t|dd�}|dk	rRt|tj�rR||t|��n|j|tj��dS)N�addSkip)	�_ErrorHolderr	rrZSkipTestr)ZaddErrorrR�exc_info)rr.Z	exceptionrN�errorrVrrrrI�s
z)TestSuite._addClassOrModuleLevelExceptionc Cs�|j|�}|dkrdS|jr,dSytj|}Wntk
rUdSYnXt|dd�}|dk	r�t|d�zfy|�WnTtk
r�}z4t|t	�r��d|}|j
|||�WYdd}~XnXWdt|d�XdS)N�tearDownModulerFztearDownModule (%s)rG)rPr<rRrSrTr	r
rHrrCrI)rr.rOrUrZrLrNrrrrB�s(	
	

*zTestSuite._handleModuleTearDownc	Cs"t|dd�}|j}||kr+dSt|dd�rAdSt|dd�rWdSt|dd�rmdSt|dd�}|dk	rt|d�zuy|�Wnctk
r}zCt|t�r��tj|�}d|}|j|||�WYdd}~XnXWdt|d	�XdS)
NrAr;Fr<rD�
tearDownClassrFztearDownClass (%s)rG)	r	rr
rHrrCrrrI)	rr r.rJrKr[rLrMrNrrrr>�s,	

*z TestSuite._tearDownPreviousClassN)r6r7r8r9r0r5r@rPr?rIrBr>rrrrr\s! c@s|eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rWz�
    Placeholder for a TestCase inside a result. As far as a TestResult
    is concerned, this looks exactly like a unit test. Used to insert
    arbitrary errors into a test suite run.
    NcCs
||_dS)N)�description)rr\rrrrsz_ErrorHolder.__init__cCs|jS)N)r\)rrrr�idsz_ErrorHolder.idcCsdS)Nr)rrrr�shortDescription sz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>)r\)rrrrr#sz_ErrorHolder.__repr__cCs
|j�S)N)r])rrrr�__str__&sz_ErrorHolder.__str__cCsdS)Nr)rr.rrrr0)sz_ErrorHolder.runcCs
|j|�S)N)r0)rr.rrrr4.sz_ErrorHolder.__call__cCsdS)Nrr)rrrrr1sz_ErrorHolder.countTestCases)
r6r7r8r9ZfailureExceptionrr]r^rr_r0r4rrrrrrWsrWcCs+yt|�Wntk
r&dSYnXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)rr")r rrrr=4s

	r=c@s(eZdZdZdZdZdZdS)rCzCUsed by the TestSuite to hold previous class when running in debug.NF)r6r7r8r9rAr<r+rrrrrC=srC)
r9rR�rrZ
__unittestr
�objectrrrWr=rCrrrr�<module>sL�&