o }5hs@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/lib/python3.10/unittest/runner.py__init__s z_WritelnDecorator.__init__cCs|dvrt|t|j|S)N)r __getstate__)AttributeErrorgetattrr)rattrr r r __getattr__s z_WritelnDecorator.__getattr__NcCs|r|||ddSN )write)rargr r r writelns z_WritelnDecorator.writelnr)__name__ __module__ __qualname____doc__r rrr r r r r s rcseZdZdZdZdZfddZddZfdd 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__cCs,|}|jr|rdt||fSt|Sr)shortDescriptionrjoinstr)rtestdoc_first_liner r r getDescription,s zTextTestResult.getDescriptioncsFtt|||jr!|j|||jd|jdSdS)Nz ... )rr startTestrrrr'flushrr%r r r r(3s  zTextTestResult.startTestcTtt|||jr|jd|jdS|jr(|jd|jdSdS)Nok.) rr addSuccessrrrr)rrr*r r r r.:  zTextTestResult.addSuccesscVtt||||jr|jd|jdS|jr)|jd|jdSdS)NERRORE) rraddErrorrrrr)rrrr%errr r r r3C  zTextTestResult.addErrorcr0)NFAILF) rr addFailurerrrr)rrr4r r r r9Lr6zTextTestResult.addFailurecs\tt||||jr|jd||jdS|jr,|j d|jdSdS)Nz skipped {0!r}s) rraddSkiprrrformatr)rr)rr%reasonr r r r;Us zTextTestResult.addSkipcr0)Nzexpected failurex) rraddExpectedFailurerrrr)rrr4r r r r?^r6z!TextTestResult.addExpectedFailurecr+)Nzunexpected successu) rraddUnexpectedSuccessrrrr)rrr*r r r rAgr/z#TextTestResult.addUnexpectedSuccesscCs@|js|jr|j|j|d|j|d|jdS)Nr1r7)rrrrr)printErrorListerrorsfailuresrr r r printErrorsps   zTextTestResult.printErrorscCsb|D],\}}|j|j|jd|||f|j|j|jd||jqdS)Nz%s: %sz%s)rr separator1r' separator2r))rflavourrCr%r5r r r rBws  zTextTestResult.printErrorList)rrrrrGrHr r'r(r.r3r9r;r?rArFrB __classcell__r r r r rs     rc@s8eZdZdZeZ  d 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 CsR|durtj}t||_||_||_||_||_||_||_ |dur'||_ dSdS)zConstruct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) sysstderrrrrrfailfastbufferrLwarnings resultclass) rrrrrOrPrRrQrLr r r r s  zTextTestRunner.__init__cCs||j|j|jSr)rRrrrrEr r r _makeResultszTextTestRunner._makeResultc Cs^|}t||j|_|j|_|j|_tV|jr/t|j|jdvr/tjdt ddt }t |dd}|dur@|z||Wt |dd}|durS|nt |dd}|durb|wwt }Wdn1sqwY||}| t|dr|j|j|j}|jd ||d krd pd |f|jd } } } z tt|j|j|jf} Wn tyYnw| \} } } g} |s|jdt|jt|j}}|r| d||r| d|n|jd| r| d| | r| d| | r| d| | r"|jdd| fn|jd|j|S)z&Run the given test case or test suite.)defaultalwaysmodulezPlease use assert\w+ instead.)categorymessage startTestRunN stopTestRunrHzRan %d test%s in %.3fsrr:rFAILEDz failures=%dz errors=%dOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r) rSrrOrPrLrQcatch_warnings simplefilterfilterwarningsDeprecationWarningtime perf_counterrrFhasattrrrrHtestsRunmaplenexpectedFailuresunexpectedSuccessesskippedr wasSuccessfulrrDrCappendr#r))rr%r startTimerYrZstopTime timeTakenrun expectedFailsrirjresultsinfosfailederroredr r r rps                 zTextTestRunner.run)NTrFFNN) rrrrrrRr rSrpr r r r rKs  rK)rrMrbrQr[rsignalsr __unittestobjectr TestResultrrKr r r r s  c