B � fW�@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/python37/lib64/python3.7/unittest/runner.py�__init__sz_WritelnDecorator.__init__cCs|dkrt|��t|j|�S)N)r� __getstate__)�AttributeError�getattrr)r�attrrrr � __getattr__sz_WritelnDecorator.__getattr__NcCs|r|�|�|�d�dS)N� )�write)r�argrrr �writelns z_WritelnDecorator.writeln)N)�__name__� __module__� __qualname__�__doc__r rrrrrr 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__rr r %s   zTextTestResult.__init__cCs0|��}|jr$|r$d�t|�|f�St|�SdS)Nr)ZshortDescriptionr�join�str)r�testZdoc_first_linerrr �getDescription,s zTextTestResult.getDescriptioncsBtt|��|�|jr>|j�|�|��|j�d�|j��dS)Nz ... )rr� startTestrrrr"�flush)rr!)rrr r#3s  zTextTestResult.startTestcsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)N�ok�.) rr� addSuccessrrrrrr$)rr!)rrr r':s  zTextTestResult.addSuccesscsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�ERROR�E) rr�addErrorrrrrrr$)rr!�err)rrr r*Bs  zTextTestResult.addErrorcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)N�FAIL�F) rr� addFailurerrrrrr$)rr!r+)rrr r.Js  zTextTestResult.addFailurecsLtt|��||�|jr,|j�d�|��n|jrH|j�d�|j� �dS)Nz skipped {0!r}�s) rr�addSkiprrr�formatrrr$)rr!�reason)rrr r0Rs  zTextTestResult.addSkipcsFtt|��||�|jr&|j�d�n|jrB|j�d�|j��dS)Nzexpected failure�x) rr�addExpectedFailurerrrrrr$)rr!r+)rrr r4Zs  z!TextTestResult.addExpectedFailurecsDtt|��|�|jr$|j�d�n|jr@|j�d�|j��dS)Nzunexpected success�u) rr�addUnexpectedSuccessrrrrrr$)rr!)rrr r6bs  z#TextTestResult.addUnexpectedSuccesscCs6|js |jr|j��|�d|j�|�d|j�dS)Nr(r,)rrrr�printErrorList�errors�failures)rrrr � printErrorsjs  zTextTestResult.printErrorscCs\xV|D]N\}}|j�|j�|j�d||�|�f�|j�|j�|j�d|�qWdS)Nz%s: %sz%s)rr� separator1r"� separator2)rZflavourr8r!r+rrr r7ps zTextTestResult.printErrorList)rrrrr;r<r r"r#r'r*r.r0r4r6r:r7� __classcell__rr)rr 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|dkrtj}t|�|_||_||_||_||_||_||_ |dk rJ||_ dS)z�Construct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) �sys�stderrrrrr�failfast�bufferr?�warnings� resultclass) rrrrrBrCrErDr?rrr r �s zTextTestRunner.__init__cCs|�|j|j|j�S)N)rErrr)rrrr � _makeResult�szTextTestRunner._makeResultc Cs2|��}t|�|j|_|j|_|j|_t����|jr^t�|j�|jdkr^tjdt dd�t � �}t |dd�}|dk r�|�z ||�Wdt |dd�}|dk r�|�Xt � �}WdQRX||}|� �t|d�r�|j�|j�|j}|j�d ||d ko�d �pd |f�|j��d } } } ytt|j|j|jf�} Wntk �rTYn X| \} } } g} |���s�|j�d�t|j�t|j�}}|�r�| �d|�|�r�| �d|�n |j�d�| �r�| �d| �| �r�| �d| �| �r| �d| �| �r"|j�dd�| �f�n |j�d�|S)z&Run the given test case or test suite.)�default�always�modulezPlease use assert\w+ instead.)�category�message� startTestRunN� stopTestRunr<zRan %d test%s in %.3fsrr/�rZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rFrrBrCr?rD�catch_warnings� simplefilter�filterwarnings�DeprecationWarning�timeZ perf_counterr r:�hasattrrrr<ZtestsRun�map�lenZexpectedFailures�unexpectedSuccesses�skippedr Z wasSuccessfulrr9r8�appendr)rr!rZ startTimerLrMZstopTimeZ timeTaken�runZ expectedFailsrWrXZresultsZinfosZfailedZerroredrrr rZ�sr              zTextTestRunner.run)NTrFFNN) rrrrrrEr rFrZrrrr r>xsr>)rr@rSrDrNrZsignalsrZ __unittest�objectrZ TestResultrr>rrrr �s  [