U ,aW@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 4/opt/alt/python38/lib64/python3.8/unittest/runner.py__init__sz_WritelnDecorator.__init__cCs|dkrt|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.startTestcsDtt|||jr$|jdn|jr@|jd|jdS)Nok.) rr addSuccessrrrrrr'r(r r r r+:s  zTextTestResult.addSuccesscsFtt||||jr&|jdn|jrB|jd|jdS)NERRORE) rraddErrorrrrrrr'rr$errr r r r.Bs  zTextTestResult.addErrorcsFtt||||jr&|jdn|jrB|jd|jdS)NFAILF) rr addFailurerrrrrr'r/r r r r3Js  zTextTestResult.addFailurecsLtt||||jr,|jd|n|jrH|jd|j dS)Nz skipped {0!r}s) rraddSkiprrrformatrrr')rr$reasonr r r r5Rs  zTextTestResult.addSkipcsFtt||||jr&|jdn|jrB|jd|jdS)Nzexpected failurex) rraddExpectedFailurerrrrrr'r/r r r r9Zs  z!TextTestResult.addExpectedFailurecsDtt|||jr$|jdn|jr@|jd|jdS)Nzunexpected successu) rraddUnexpectedSuccessrrrrrr'r(r r r r;bs  z#TextTestResult.addUnexpectedSuccesscCs6|js |jr|j|d|j|d|jdS)Nr,r1)rrrrprintErrorListerrorsfailuresrr r r printErrorsjs  zTextTestResult.printErrorscCsX|D]N\}}|j|j|jd|||f|j|j|jd|qdS)Nz%s: %sz%s)rr separator1r% separator2)rZflavourr=r$r0r r r r<ps  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|dkrtj}t||_||_||_||_||_||_||_ |dk rJ||_ dS)zConstruct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) sysstderrrrrrfailfastbufferrEwarnings resultclass) rrrrrHrIrKrJrEr r r r s zTextTestRunner.__init__cCs||j|j|jSr)rKrrrr?r r r _makeResultszTextTestRunner._makeResultc Cs2|}t||j|_|j|_|j|_t|jr^t|j|jdkr^tjdt ddt }t |dd}|dk r|z ||W5t |dd}|dk r|Xt }W5QRX||}| t|dr|j|j|j}|jd ||d kod pd |f|jd } } } ztt|j|j|jf} Wntk rTYn X| \} } } g} |s|jdt|jt|j}}|r| d||r| d|n |jd| r| d| | r| d| | r| d| | r"|jdd| fn |jd|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)rLrrHrIrErJcatch_warnings simplefilterfilterwarningsDeprecationWarningtime perf_counterrr@hasattrrrrBZtestsRunmaplenZexpectedFailuresunexpectedSuccessesskippedr Z wasSuccessfulrr>r=appendr")rr$rZ startTimerRrSZstopTimeZ timeTakenrunZ expectedFailsr^r_ZresultsZinfosZfailedZerroredr r r rasx               zTextTestRunner.run)NTrFFNN) rrrrrrKr rLrar r r r rDxs rD)rrFrYrJrTrZsignalsrZ __unittestobjectrZ TestResultrrDr r r r s  [