a XC?hs�@sndZddlZddlZddlZddlmZddlmZdZGdd�de �Z Gd d �d ej �Z Gd d �d e �Z dS) z Running tests�N�)�result)�registerResultTc@s*eZdZdZdd�Zdd�Zd dd�ZdS) �_WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs ||_dS�N)�stream)�selfr�r �4/opt/alt/python39/lib64/python3.9/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dvrt|��t|j|�S)N)r� __getstate__)�AttributeError�getattrr)r�attrr r r � __getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS�N� )�write)r�argr r r �writelns z_WritelnDecorator.writeln)N)�__name__� __module__� __qualname__�__doc__r rrr r r r r srcs�eZdZdZdZdZ�fdd�Zdd�Z�fdd �Z�fd d �Z �fd d �Z �fdd�Z �fdd�Z �fdd�Z �fdd�Zdd�Zdd�Z�ZS)�TextTestResultzhA test result class that can print formatted text results to a stream. Used by TextTestRunner. zF======================================================================zF----------------------------------------------------------------------cs8tt|��|||�||_|dk|_|dk|_||_dS)Nr)�superrr r�showAll�dots� descriptions)rrr� verbosity�� __class__r r r %s   zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdSr)ZshortDescriptionr�join�str)r�testZdoc_first_liner r r �getDescription,s zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr� startTestrrrr%�flush�rr$r r r r&3s  zTextTestResult.startTestcsNtt|��|�|jr.|j�d�|j��n|jrJ|j�d�|j��dS)N�ok�.) rr� addSuccessrrrr'rrr(r r r r+:s   zTextTestResult.addSuccesscsPtt|��||�|jr0|j�d�|j��n|jrL|j�d�|j��dS)N�ERROR�E) rr�addErrorrrrr'rr�rr$�errr r r r.Cs   zTextTestResult.addErrorcsPtt|��||�|jr0|j�d�|j��n|jrL|j�d�|j��dS)N�FAIL�F) rr� addFailurerrrr'rrr/r r r r3Ls   zTextTestResult.addFailurecsVtt|��||�|jr6|j�d�|��|j��n|jrR|j� d�|j��dS)Nz skipped {0!r}�s) rr�addSkiprrr�formatr'rr)rr$�reasonr r r r5Us  zTextTestResult.addSkipcsPtt|��||�|jr0|j�d�|j��n|jrL|j�d�|j��dS)Nzexpected failure�x) rr�addExpectedFailurerrrr'rrr/r r r r9^s   z!TextTestResult.addExpectedFailurecsNtt|��|�|jr.|j�d�|j��n|jrJ|j�d�|j��dS)Nzunexpected success�u) rr�addUnexpectedSuccessrrrr'rrr(r r r r;gs   z#TextTestResult.addUnexpectedSuccesscCs@|js |jr |j��|j��|�d|j�|�d|j�dS)Nr,r1)rrrrr'�printErrorList�errors�failures�rr r r � printErrorsps    zTextTestResult.printErrorscCsb|D]X\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�|j��qdS)Nz%s: %sz%s)rr� separator1r%� separator2r')rZflavourr=r$r0r r r r<ws  zTextTestResult.printErrorList)rrrrrArBr r%r&r+r.r3r5r9r;r@r<� __classcell__r r r r rs   rc@s4eZdZdZeZd dd�dd�Zd d �Zd d �ZdS)�TextTestRunnerz�A test runner class that displays results in textual form. It prints out the names of tests as they are run, errors as they occur, and a summary of the results at the end of the test run. NTrF)� tb_localsc CsN|durtj}t|�|_||_||_||_||_||_||_ |durJ||_ dS)z�Construct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) �sys�stderrrrrr�failfast�bufferrE�warnings� resultclass) rrrrrHrIrKrJrEr r r r �s zTextTestRunner.__init__cCs|�|j|j|j�Sr)rKrrrr?r r r � _makeResult�szTextTestRunner._makeResultc Csl|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdvr^tjdt dd�t � �}t |dd�}|dur�|�z&||�Wt |dd�}|dur�|�nt |dd�}|dur�|�0t � �}Wd�n1s�0Y||}|� �t|d��r|j�|j�|j}|j�d ||d k�r4d �p6d |f�|j��d } } } ztt|j|j|jf�} Wnt�y�Yn 0| \} } } g} |���s�|j�d�t|j�t|j�}}|�r�| �d|�|�r�| �d|�n |j�d�| �r | �d| �| �r| �d| �| �r2| �d| �| �rR|j�dd�| �f�n |j�d�|j��|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message� startTestRunN� stopTestRunrBzRan %d test%s in %.3fsrr4�rZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r) rLrrHrIrErJ�catch_warnings� simplefilter�filterwarnings�DeprecationWarning�time� perf_counterrr@�hasattrrrrBZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr Z wasSuccessfulrr>r=�appendr"r')rr$rZ startTimerRrSZstopTimeZ timeTaken�runZ expectedFailsr^r_ZresultsZinfosZfailedZerroredr r r ra�s�   �   � & �  �       zTextTestRunner.run)NTrFFNN) rrrrrrKr rLrar r r r rD�s�� rD)rrFrYrJrTrZsignalsrZ __unittest�objectrZ TestResultrrDr r r r �s  c