a DOgs@sndZddlZddlZddlZddlmZddlmZdZGddde Z Gd d d ej Z Gd d d e Z dS) z Running testsN)result)registerResultTc@s*eZdZdZddZddZd ddZdS) _WritelnDecoratorz@Used to decorate file-like objects with a handy 'writeln' methodcCs ||_dSN)stream)selfrr '/usr/lib64/python3.9/unittest/runner.py__init__sz_WritelnDecorator.__init__cCs|dvrt|t|j|S)N)r __getstate__)AttributeErrorgetattrr)rattrr r r __getattr__sz_WritelnDecorator.__getattr__NcCs|r|||ddSN )write)rargr r r writelns z_WritelnDecorator.writeln)N)__name__ __module__ __qualname____doc__r rrr r r r r srcseZdZdZdZdZfddZddZfdd Zfd d Z fd d Z fddZ fddZ fddZ fddZddZddZZS)TextTestResultzhA test result class that can print formatted text results to a stream. Used by TextTestRunner. zF======================================================================zF----------------------------------------------------------------------cs8tt||||||_|dk|_|dk|_||_dS)Nr)superrr rshowAlldots descriptions)rrr verbosity __class__r r r %s   zTextTestResult.__init__cCs0|}|jr$|r$dt||fSt|SdSr)ZshortDescriptionrjoinstr)rtestZdoc_first_liner r r getDescription,s zTextTestResult.getDescriptioncsBtt|||jr>|j|||jd|jdS)Nz ... )rr startTestrrrr%flushrr$r r r r&3s  zTextTestResult.startTestcsNtt|||jr.|jd|jn|jrJ|jd|jdS)Nok.) rr addSuccessrrrr'rrr(r r r r+:s   zTextTestResult.addSuccesscsPtt||||jr0|jd|jn|jrL|jd|jdS)NERRORE) rraddErrorrrrr'rrrr$errr r r r.Cs   zTextTestResult.addErrorcsPtt||||jr0|jd|jn|jrL|jd|jdS)NFAILF) rr addFailurerrrr'rrr/r r r r3Ls   zTextTestResult.addFailurecsVtt||||jr6|jd||jn|jrR|j d|jdS)Nz skipped {0!r}s) rraddSkiprrrformatr'rr)rr$reasonr r r r5Us  zTextTestResult.addSkipcsPtt||||jr0|jd|jn|jrL|jd|jdS)Nzexpected failurex) rraddExpectedFailurerrrr'rrr/r r r r9^s   z!TextTestResult.addExpectedFailurecsNtt|||jr.|jd|jn|jrJ|jd|jdS)Nzunexpected successu) rraddUnexpectedSuccessrrrr'rrr(r r r r;gs   z#TextTestResult.addUnexpectedSuccesscCs@|js |jr |j|j|d|j|d|jdS)Nr,r1)rrrrr'printErrorListerrorsfailuresrr r r printErrorsps    zTextTestResult.printErrorscCsb|D]X\}}|j|j|jd|||f|j|j|jd||jqdS)Nz%s: %sz%s)rr separator1r% separator2r')rflavourr=r$r0r r r r<ws  zTextTestResult.printErrorList)rrrrrArBr r%r&r+r.r3r5r9r;r@r< __classcell__r r r r rs   rc@s4eZdZdZeZd ddddZd d Zd d ZdS)TextTestRunnerzA 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)zConstruct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) sysstderrrrrrfailfastbufferrFwarnings resultclass) rrrrrIrJrLrKrFr r r r s zTextTestRunner.__init__cCs||j|j|jSr)rLrrrr?r r r _makeResultszTextTestRunner._makeResultc Csl|}t||j|_|j|_|j|_t|jr^t|j|jdvr^tjdt ddt }t |dd}|dur|z&||Wt |dd}|dur|nt |dd}|dur|0t }Wdn1s0Y||}| t|dr|j|j|j}|jd ||d kr4d p6d |f|jd } } } ztt|j|j|jf} WntyYn 0| \} } } g} |s|jdt|jt|j}}|r| d||r| d|n |jd| r | d| | r| d| | r2| d| | rR|jdd| fn |jd|j|S)z&Run the given test case or test suite.)defaultalwaysmodulezPlease use assert\w+ instead.)categorymessage startTestRunN stopTestRunrBzRan %d test%s in %.3fsrr4rZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r) rMrrIrJrFrKcatch_warnings simplefilterfilterwarningsDeprecationWarningtime perf_counterrr@hasattrrrrBZtestsRunmaplenZexpectedFailuresunexpectedSuccessesskippedr Z wasSuccessfulrr>r=appendr"r')rr$rZ startTimerSrTZstopTimeZ timeTakenrunZ expectedFailsr_r`resultsZinfosZfailedZerroredr r r rbs       &          zTextTestRunner.run)NTrFFNN) rrrrrrLr rMrbr r r r rEs rE)rrGrZrKrUrZsignalsrZ __unittestobjectrZ TestResultrrEr r r r s  c