Your IP : 3.129.194.30


Current Path : /usr/lib64/python3.8/unittest/__pycache__/
Upload File :
Current File : //usr/lib64/python3.8/unittest/__pycache__/suite.cpython-38.pyc

U

e5d2�@s|dZddlZddlmZddlmZdZdd�ZGd	d
�d
e�ZGdd�de�Z	Gdd
�d
e�Z
dd�ZGdd�de�ZdS)�	TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcSsdS�N�rrr�&/usr/lib64/python3.8/unittest/suite.py�<lambda>�z!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr�_call_if_existssrc@sneZdZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�
BaseTestSuitezNA simple test suite that doesn't provide class or module shared fixtures.
    TrcCsg|_d|_|�|�dS�Nr)�_tests�_removed_tests�addTests)�self�testsrrr�__init__szBaseTestSuite.__init__cCsdt�|j�t|�fS)Nz
<%s tests=%s>)r�strclass�	__class__�list�rrrr�__repr__szBaseTestSuite.__repr__cCs t||j�stSt|�t|�kSr)�
isinstancer�NotImplementedr)r�otherrrr�__eq__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr�__iter__"szBaseTestSuite.__iter__cCs$|j}|D]}|r
||��7}q
|Sr)r�countTestCases)rZcases�testrrrr#%s
zBaseTestSuite.countTestCasescCsLt|�std�t|����t|t�r<t|tjt	f�r<td��|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��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr&r-)rrr$rrrr6s
zBaseTestSuite.addTestscCs8t|�D]*\}}|jrq4||�|jr|�|�q|Sr)�	enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr$rrr�run<szBaseTestSuite.runcCsNz|j|}Wntk
r"Yn(Xt|d�r@|j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r#N)rr&�hasattrrr#)rr4r$rrrr2Es
z BaseTestSuite._removeTestAtIndexcOs|j||�Sr�r5)r�args�kwdsrrr�__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr,rrrr<VszBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r1rrr r"r#r-rr5r2r:r<rrrrrs

	rc@s^eZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zddd�Z	ddd�Z
dd�Zdd�Zd
S)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�dkrd|_}t|�D]�\}}|jr8q�t|�r�|�||�|�||�|�||�|j|_	t|jdd�s&t|dd�r�q&|s�||�n|�
�|jr&|�|�q&|r�|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrAr/r0�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr<r1r2�_handleModuleTearDown)rr3r<ZtopLevelr4r$rrrr5fs2

�

z
TestSuite.runcCst�}|�|d�dS)r;TN)�_DebugResultr5)rr<rrrr<�szTestSuite.debugc	Cs2t|dd�}|j}||krdS|jr(dSt|dd�r8dSz
d|_Wntk
rVYnXt|dd�}|dk	�r.t|d�z^z
|�WnNt
k
r�}z0t|t�r��d|_t
�|�}|�	||d|�W5d}~XYnXW5t|d�|jdk�r,|��t|j�dk�r,|jD]}|j	||d	d||d
��qXdS)NrH�__unittest_skip__F�
setUpClass�_setupStdout�_restoreStdoutTrr��info)rrrCrBr&r�doClassCleanups�len�tearDown_exceptions�"_createClassOrModuleLevelException�	ExceptionrrJrr)	rr$r3�
previousClass�currentClassrL�exc�	className�errrrG�sL





�

�zTestSuite._handleClassSetUpcCs"d}t|dd�}|dk	r|j}|S)NrH)rr>)rr3�previousModulerVrrr�_get_previous_module�s
zTestSuite._get_previous_modulec	
Cs|�|�}|jj}||krdS|�|�d|_ztj|}Wntk
rRYdSXt|dd�}|dk	�rt	|d�z�z
|�Wn�t
k
�r}zfzt��Wn2t
k
r�}z|�
||d|�W5d}~XYnXt|t�r�d|_|�
||d|�W5d}~XYnXW5t	|d�XdS)NF�setUpModulerMrNT)r\rr>rIrC�sys�modules�KeyErrorrrrUr�doModuleCleanupsrTrrJ)	rr$r3r[Z
currentModule�moduler]rZrXrrrrF�s>




�
�zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr3rXZmethod_namerrP�	errorNamerrrrT�sz,TestSuite._createClassOrModuleLevelExceptioncCs^t|�}t|dd�}|dk	r8t|tj�r8||t|��n"|sN|�|t���n|�||�dS)N�addSkip)	�_ErrorHolderrrrZSkipTestr.ZaddErrorr^�exc_info)rr3Z	exceptionrerP�errorrfrrrrd�sz)TestSuite._addClassOrModuleLevelExceptioncCs|�|�}|dkrdS|jr dSztj|}Wntk
rDYdSXt|dd�}|dk	�rt|d�zNz
|�Wn>t	k
r�}z t|t�r��|�
||d|�W5d}~XYnXW5t|d�zt��Wn4t	k
�r}z|�
||d|�W5d}~XYnXXdS)N�tearDownModulerMrN)
r\rCr^r_r`rrrrarUrTrrJ)rr3r[rbrjrZrrrrI�s:




�
�zTestSuite._handleModuleTearDownc	Cst|dd�}|j}||krdSt|dd�r.dSt|dd�r>dSt|dd�rNdSt|dd�}|dk	�rt|d�zXz
|�WnHt	k
r�}z*t
|t�r��t�|�}|�||d|�W5d}~XYnXW5t|d�|��t|j�d	k�r|jD]&}t�|�}|j||d
d||d�q�XdS)NrHrBFrCrK�
tearDownClassrMrNrrrO)rrrrQrRrSrrrTrUrrJ)	rr$r3rVrWrkrXrYrZrrrrEsB




�


�z TestSuite._tearDownPreviousClass)F)N)N)
r=r>r?r@r5r<rGr\rFrTrdrIrErrrrr\s	
!($�
�
 c@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)rgz�
    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
||_dSr��description)rrmrrrrBsz_ErrorHolder.__init__cCs|jSrrlrrrr�idEsz_ErrorHolder.idcCsdSrrrrrr�shortDescriptionHsz_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rlrrrrrKsz_ErrorHolder.__repr__cCs|��Sr)rnrrrr�__str__Nsz_ErrorHolder.__str__cCsdSrr�rr3rrrr5Qsz_ErrorHolder.runcCs
|�|�Srr7rqrrrr:Vsz_ErrorHolder.__call__cCsdSrrrrrrr#Ysz_ErrorHolder.countTestCases)
r=r>r?r@ZfailureExceptionrrnrorrpr5r:r#rrrrrg6s	rgcCs(zt|�Wntk
r"YdSXdS)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r&)r$rrrrD\s
rDc@seZdZdZdZdZdZdS)rJzCUsed by the TestSuite to hold previous class when running in debug.NF)r=r>r?r@rHrCr0rrrrrJesrJ)
r@r^�rrZ
__unittestr�objectrrrgrDrJrrrr�<module>sL[&	

?>