U ÙAT^Wc@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__óz_WritelnDecorator.__init__cCs|dkrt|ƒ‚t|j|ƒS)N)rZ __getstate__)ÚAttributeErrorÚgetattrr)rZattrrrr Ú __getattr__sz_WritelnDecorator.__getattr__NcCs|r| |¡| d¡dS©NÚ )Úwrite)rZargrrr Úwritelns z_WritelnDecorator.writelnr)Ú__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©Z __class__rr r %s   zTextTestResult.__init__cCs0| ¡}|jr$|r$d t|ƒ|f¡St|ƒSdSr)ZshortDescriptionrÚjoinZstr)rÚtestZdoc_first_linerrr ÚgetDescription,s zTextTestResult.getDescriptioncsBtt|ƒ |¡|jr>|j | |¡¡|j d¡|j ¡dS)Nz ... )rrÚ startTestrrrr Úflush©rrrrr r!3s  zTextTestResult.startTestcóDtt|ƒ |¡|jr$|j d¡n|jr@|j d¡|j ¡dS)NZokZ.) rrÚ addSuccessrrrrrr"r#rrr r%:ó  zTextTestResult.addSuccesscóFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)NÚERRORZE) rrÚaddErrorrrrrrr"©rrÚerrrrr r)Bó  zTextTestResult.addErrorcr')NÚFAILZF) rrÚ addFailurerrrrrr"r*rrr r.Jr,zTextTestResult.addFailurecsLtt|ƒ ||¡|jr,|j d |¡¡n|jrH|j d¡|j  ¡dS)Nz skipped {0!r}Ús) rrÚaddSkiprrrZformatrrr")rrZreasonrrr r0Rs  zTextTestResult.addSkipcr')Nzexpected failureZx) rrÚaddExpectedFailurerrrrrr"r*rrr r1Zr,z!TextTestResult.addExpectedFailurecr$)Nzunexpected successZu) rrÚaddUnexpectedSuccessrrrrrr"r#rrr r2br&z#TextTestResult.addUnexpectedSuccesscCs6|js |jr|j ¡| d|j¡| d|j¡dS)Nr(r-)rrrrÚprintErrorListÚerrorsÚfailures©rrrr Ú printErrorsjs  zTextTestResult.printErrorscCsX|D]N\}}|j |j¡|j d|| |¡f¡|j |j¡|j d|¡qdS)Nz%s: %sz%s)rrÚ separator1r Ú separator2)rZflavourr4rr+rrr r3ps  zTextTestResult.printErrorList)rrrrr8r9r r r!r%r)r.r0r1r2r7r3Z __classcell__rrrr 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) ÚsysZstderrrrrrÚfailfastÚbufferr;ÚwarningsÚ resultclass) rrrrr=r>r@r?r;rrr r €s zTextTestRunner.__init__cCs| |j|j|j¡Sr)r@rrrr6rrr Ú _makeResult”r zTextTestRunner._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.)ZdefaultZalwaysZmodulezPlease use assert\w+ instead.)ZcategoryZmessageÚ startTestRunNÚ stopTestRunr9zRan %d test%s in %.3fsrr/ÚrZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rArr=r>r;r?Zcatch_warningsZ simplefilterZfilterwarningsZDeprecationWarningÚtimeZ perf_counterr r7Zhasattrrrr9ZtestsRunZmapZlenZexpectedFailuresÚunexpectedSuccessesÚskippedr Z wasSuccessfulrr5r4Zappendr)rrrZ startTimerBrCZstopTimeZ timeTakenÚrunZ expectedFailsrFrGZresultsZinfosZfailedZerroredrrr rH—sx   þ    ÿ  þ      zTextTestRunner.run)NTrFFNN) rrrrrr@r rArHrrrr r:xsÿþ r:)rr<rEr?rDrZsignalsrZ __unittestZobjectrZ TestResultrr:rrrr Zs  [