Your IP : 3.141.14.210
o
S�g�4�@s|dZddlZddlmZddlmZdZdd�ZGd d
�d
e�ZGdd�de�Z Gdd
�d
e�Z
dd�ZGdd�de�ZdS)� TestSuite�N�)�case)�utilTcCst||dd��}|�dS)NcS�dS�N�rrr�5/opt/alt/python310/lib64/python3.10/unittest/suite.py�<lambda>sz!_call_if_exists.<locals>.<lambda>)�getattr)�parent�attr�funcrrr �_call_if_existss
rc@sneZdZdZdZddd�Zdd�Zdd �Zd
d�Zdd
�Z dd�Z
dd�Zdd�Zdd�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__szBaseTestSuite.__eq__cCs
t|j�Sr)�iterrrrrr �__iter__"�
zBaseTestSuite.__iter__cCs$|j}|D]
}|r||��7}q|Sr)r�countTestCases)r�cases�testrrr r$%s�zBaseTestSuite.countTestCasescCsLt|�s
td�t|����t|t�rt|tjt f�rtd��|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�r td��|D]}|�|�qdS)Nz0tests must be an iterable of tests, not a string)r�strr(r/)rrr&rrr r6s
�zBaseTestSuite.addTestscCs:t|�D]\}}|jr|S||�|jr|�|�q|Sr)� enumerate�
shouldStop�_cleanup�_removeTestAtIndex)r�result�indexr&rrr �run<s�
�zBaseTestSuite.runcCsNz|j|}Wn
tyYdSwt|d�r |j|��7_d|j|<dS)z2Stop holding a reference to the TestCase at index.r$N)rr(�hasattrrr$)rr6r&rrr r4Es�
z BaseTestSuite._removeTestAtIndexcOs|j|i|��Sr�r7)r�args�kwdsrrr �__call__SszBaseTestSuite.__call__cCs|D]}|��qdS)�7Run the tests without collecting errors in a TestResultN)�debugr.rrr r>Vs
�zBaseTestSuite.debugN)r)�__name__�
__module__�__qualname__�__doc__r3rrr r"r$r/rr7r4r<r>rrrr rs
rc@sbeZdZdZddd�Zdd�Zdd�Zd d
�Zdd�Z
ddd�Z
ddd�Z
dd�Zdd�Zd
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�durd|_}t|�D]D\}}|jrn<t|�rD|�||�|�||�|�||�|j|_ t|jdd�sCt|dd�rDq|sK||�n|�
�|jrW|�|�q|rh|�d|�|�
|�d|_|S)NF�_testRunEnteredT�_classSetupFailed�_moduleSetUpFailed)rrCr1r2�_isnotsuite�_tearDownPreviousClass�_handleModuleFixture�_handleClassSetUpr�_previousTestClassr>r3r4�_handleModuleTearDown)rr5r>ZtopLevelr6r&rrr r7fs4
�
�
z
TestSuite.runcCst�}|�|d�dS)r=TN)�_DebugResultr7)rr>rrr r>�szTestSuite.debugcCstt|dd�}|j}||krdS|jrdSt|dd�rdSd}zd|_Wn ty,Ynwt|dd�}t|dd�}|dur�t|d�zoz|�Wn6ty~}z*t|t�rV�d}zd|_Wn tyfYnwt �
|�} |�||d| �WYd}~nd}~ww|r�|dur�|�|jD]}
|j||
dd| |
d �q�Wt|d
�dSWt|d
�dSWt|d
�dSt|d
�wdS)NrJ�__unittest_skip__F�
setUpClass�doClassCleanups�_setupStdoutTr��info�_restoreStdout)
rrrErDr(r� ExceptionrrLrr�"_createClassOrModuleLevelException�tearDown_exceptions)rr&r5�
previousClass�currentClassZfailedrNrO�e� className�exc_inforrr rI�sf
�
�
���
�����zTestSuite._handleClassSetUpcCs"d}t|dd�}|dur|j}|S)NrJ)rr@)rr5�previousModulerWrrr �_get_previous_module�s
zTestSuite._get_previous_modulec
CsL|�|�}|jj}||krdS|�|�d|_ztj|}Wn
ty(YdSwt|dd�}|dur�t |d�zez|�Wn#t
ya}zt|t�rL�d|_|�
||d|�WYd}~nd}~ww|jr�zt��Wn"t
y�}z|�
||d|�WYd}~nd}~wwWt |d�dSWt |d�dSWt |d�dSt |d�wdS)NF�setUpModulerPTrS)r]rr@rKrE�sys�modules�KeyErrorrrrTrrLrUr�doModuleCleanups)rr&r5r\Z
currentModule�moduler^rYrrr rH�sX
�
����������zTestSuite._handleModuleFixtureNcCs$|�d|�d�}|�||||�dS)Nz (�))�_addClassOrModuleLevelException)rr5�excZmethod_namerrR� errorNamerrr rU�sz,TestSuite._createClassOrModuleLevelExceptioncCsbt|�}t|dd�}|durt|tj�r||t|��dS|s)|�|t���dS|�||�dS)N�addSkip) �_ErrorHolderrrrZSkipTestr0ZaddErrorr_r[)rr5Z exceptionrgrR�errorrhrrr re�sz)TestSuite._addClassOrModuleLevelExceptionc
Cs*|�|�}|durdS|jrdSztj|}Wn
ty!YdSwt|d�zgt|dd�}|durXz|�Wn tyW}zt|t �rE�|�
||d|�WYd}~nd}~wwzt��Wn ty~}zt|t �rl�|�
||d|�WYd}~n
d}~wwWt|d�dSWt|d�dSt|d�w)NrP�tearDownModulerS)
r]rEr_r`rarrrTrrLrUrrb)rr5r\rcrkrYrrr rK�sP
�
���
�����zTestSuite._handleModuleTearDownc
Csft|dd�}|j}||ks|durdSt|dd�rdSt|dd�r#dSt|dd�r+dSt|dd�}t|dd�}|durA|durAdSt|d�zf|durvz|�Wn%tyu}zt|t�r^�t�|�}|�||d|�WYd}~nd}~ww|dur�|�|j D]$} t|t�r�| d �t�|�}|j|| d d|| d
�q�Wt|d�dSWt|d�dSt|d�w)NrJrDFrErM�
tearDownClassrOrPrrQrS)
rrrrTrrLrrrUrV)
rr&r5rWrXrlrOrYrZr[rrr rGsX
���
��� z TestSuite._tearDownPreviousClass)Fr)
r?r@rArBr7r>rIr]rHrUrerKrGrrrr r\s
!.&
�
�#c@sTeZdZdZdZdd�Zdd�Zdd�Zd d
�Zdd�Z d
d�Z
dd�Zdd�ZdS)riz�
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)rrnrrr rTr#z_ErrorHolder.__init__cCs|jSrrmrrrr �idWsz_ErrorHolder.idcCrrrrrrr �shortDescriptionZ�z_ErrorHolder.shortDescriptioncCsd|jfS)Nz<ErrorHolder description=%r>rmrrrr r]sz_ErrorHolder.__repr__cCs|��Sr)rorrrr �__str__`sz_ErrorHolder.__str__cCrrr�rr5rrr r7csz_ErrorHolder.runcCs
|�|�Srr9rsrrr r<hr#z_ErrorHolder.__call__cCsdSrrrrrr r$krqz_ErrorHolder.countTestCases)
r?r@rArBZfailureExceptionrrorprrrr7r<r$rrrr riHs ricCs$zt|�WdStyYdSw)z?A crude way to tell apart testcases and suites with duck-typingTF)r!r()r&rrr rFns
��rFc@seZdZdZdZdZdZdS)rLzCUsed by the TestSuite to hold previous class when running in debug.NF)r?r@rArBrJrEr2rrrr rLws
rL)
rBr_�rrZ
__unittestr�objectrrrirFrLrrrr �<module>sLm&
?>