U ÙAT^Wã@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 ú'/usr/lib64/python3.8/unittest/runner.pyÚ__init__sz_WritelnDecorator.__init__cCs|dkrt|ƒ‚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.startTestcsDtt|ƒ |¡|jr$|j d¡n|jr@|j d¡|j ¡dS)NÚokÚ.) rrÚ addSuccessrrrrrr'r(r r r r+:s  zTextTestResult.addSuccesscsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)NÚERRORÚE) rrÚaddErrorrrrrrr'©rr$Úerrr r r r.Bs  zTextTestResult.addErrorcsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)NÚFAILÚF) rrÚ addFailurerrrrrr'r/r r r r3Js  zTextTestResult.addFailurecsLtt|ƒ ||¡|jr,|j d |¡¡n|jrH|j d¡|j  ¡dS)Nz skipped {0!r}Ús) rrÚaddSkiprrrÚformatrrr')rr$Úreasonr r r r5Rs  zTextTestResult.addSkipcsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)Nzexpected failureÚx) rrÚaddExpectedFailurerrrrrr'r/r r r r9Zs  z!TextTestResult.addExpectedFailurecsDtt|ƒ |¡|jr$|j d¡n|jr@|j d¡|j ¡dS)Nzunexpected successÚu) rrÚaddUnexpectedSuccessrrrrrr'r(r r r r;bs  z#TextTestResult.addUnexpectedSuccesscCs6|js |jr|j ¡| d|j¡| d|j¡dS)Nr,r1)rrrrÚprintErrorListÚerrorsÚfailures©rr r r Ú printErrorsjs  zTextTestResult.printErrorscCsX|D]N\}}|j |j¡|j d|| |¡f¡|j |j¡|j d|¡qdS)Nz%s: %sz%s)rrÚ separator1r%Ú separator2)rÚflavourr=r$r0r r r r<ps  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|dkrtj}t|ƒ|_||_||_||_||_||_||_ |dk rJ||_ dS)z‰Construct a TextTestRunner. Subclasses should accept **kwargs to ensure compatibility as the interface changes. N) ÚsysÚstderrrrrrÚfailfastÚbufferrFÚwarningsÚ resultclass) rrrrrIrJrLrKrFr r r r €s zTextTestRunner.__init__cCs| |j|j|j¡Sr)rLrrrr?r r r Ú _makeResult”szTextTestRunner._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|dƒrä|j |j¡|j}|j d ||d koþd pd |f¡|j ¡d } } } ztt|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Ú stopTestRunrBzRan %d test%s in %.3fsrr4ÚrZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rMrrIrJrFrKÚcatch_warningsÚ simplefilterÚfilterwarningsÚDeprecationWarningÚtimeÚ perf_counterrr@ÚhasattrrrrBZtestsRunÚmapÚlenZexpectedFailuresÚunexpectedSuccessesÚskippedr Z wasSuccessfulrr>r=Úappendr")rr$rZ startTimerSrTZstopTimeZ timeTakenÚrunZ expectedFailsr_r`ÚresultsZinfosZfailedZerroredr r r rb—sx   þ    ÿ  þ      zTextTestRunner.run)NTrFFNN) rrrrrrLr rMrbr r r r rExsÿþ rE)rrGrZrKrUrZsignalsrZ __unittestÚobjectrZ TestResultrrEr r r r Ús  [