B °-_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/lib/python3.7/unittest/runner.pyÚ__init__sz_WritelnDecorator.__init__cCs|dkrt|ƒ‚t|j|ƒS)N)rÚ __getstate__)ÚAttributeErrorÚgetattrr)rÚattrrrr Ú __getattr__sz_WritelnDecorator.__getattr__NcCs|r| |¡| d¡dS)NÚ )Úwrite)rÚargrrr Úwritelns z_WritelnDecorator.writeln)N)Ú__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)Ú __class__rr r %s   zTextTestResult.__init__cCs0| ¡}|jr$|r$d t|ƒ|f¡St|ƒSdS)Nr)ZshortDescriptionrÚjoinÚstr)rÚtestZdoc_first_linerrr ÚgetDescription,s zTextTestResult.getDescriptioncsBtt|ƒ |¡|jr>|j | |¡¡|j d¡|j ¡dS)Nz ... )rrÚ startTestrrrr"Úflush)rr!)rrr r#3s  zTextTestResult.startTestcsDtt|ƒ |¡|jr$|j d¡n|jr@|j d¡|j ¡dS)NÚokÚ.) rrÚ addSuccessrrrrrr$)rr!)rrr r':s  zTextTestResult.addSuccesscsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)NÚERRORÚE) rrÚaddErrorrrrrrr$)rr!Úerr)rrr r*Bs  zTextTestResult.addErrorcsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)NÚFAILÚF) rrÚ addFailurerrrrrr$)rr!r+)rrr r.Js  zTextTestResult.addFailurecsLtt|ƒ ||¡|jr,|j d |¡¡n|jrH|j d¡|j  ¡dS)Nz skipped {0!r}Ús) rrÚaddSkiprrrÚformatrrr$)rr!Úreason)rrr r0Rs  zTextTestResult.addSkipcsFtt|ƒ ||¡|jr&|j d¡n|jrB|j d¡|j ¡dS)Nzexpected failureÚx) rrÚaddExpectedFailurerrrrrr$)rr!r+)rrr r4Zs  z!TextTestResult.addExpectedFailurecsDtt|ƒ |¡|jr$|j d¡n|jr@|j d¡|j ¡dS)Nzunexpected successÚu) rrÚaddUnexpectedSuccessrrrrrr$)rr!)rrr r6bs  z#TextTestResult.addUnexpectedSuccesscCs6|js |jr|j ¡| d|j¡| d|j¡dS)Nr(r,)rrrrÚprintErrorListÚerrorsÚfailures)rrrr Ú printErrorsjs  zTextTestResult.printErrorscCs\xV|D]N\}}|j |j¡|j d|| |¡f¡|j |j¡|j d|¡qWdS)Nz%s: %sz%s)rrÚ separator1r"Ú separator2)rZflavourr8r!r+rrr r7ps zTextTestResult.printErrorList)rrrrr;r<r r"r#r'r*r.r0r4r6r:r7Ú __classcell__rr)rr 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Úbufferr?ÚwarningsÚ resultclass) rrrrrBrCrErDr?rrr r €s zTextTestRunner.__init__cCs| |j|j|j¡S)N)rErrr)rrrr Ú _makeResult”szTextTestRunner._makeResultc Cs2| ¡}t|ƒ|j|_|j|_|j|_t ¡†|jr^t |j¡|jdkr^tjdt ddt   ¡}t |ddƒ}|dk r€|ƒz ||ƒWdt |ddƒ}|dk r¨|ƒXt   ¡}WdQRX||}|  ¡t|dƒrä|j |j¡|j}|j d ||d koþd pd |f¡|j ¡d } } } ytt|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Ú stopTestRunr<zRan %d test%s in %.3fsrr/ÚrZFAILEDz failures=%dz errors=%dZOKz skipped=%dzexpected failures=%dzunexpected successes=%dz (%s)z, r)rFrrBrCr?rDÚcatch_warningsÚ simplefilterÚfilterwarningsÚDeprecationWarningÚtimeZ perf_counterr r:Úhasattrrrr<ZtestsRunÚmapÚlenZexpectedFailuresÚunexpectedSuccessesÚskippedr Z wasSuccessfulrr9r8Úappendr)rr!rZ startTimerLrMZstopTimeZ timeTakenÚrunZ expectedFailsrWrXZresultsZinfosZfailedZerroredrrr rZ—sr              zTextTestRunner.run)NTrFFNN) rrrrrrEr rFrZrrrr r>xsr>)rr@rSrDrNrZsignalsrZ __unittestÚobjectrZ TestResultrr>rrrr Ús  [