3 \@sXddlZddlZddlZddlmZddlmZdZddZdZ d Z Gd d d e Z dS) N)util)wrapsTcstfdd}|S)Ncs$t|ddr|j|f||S)NfailfastF)getattrstop)selfargskw)method'/usr/lib64/python3.6/unittest/result.pyinner s zfailfast..inner)r)r rr )r r r srz Stdout: %sz Stderr: %sc@seZdZdZdZdZd-ddZddZddZd d Z d d Z d dZ ddZ ddZ eddZeddZddZddZddZddZedd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,ZdS). TestResultNFcCsbd|_g|_g|_d|_g|_g|_g|_d|_d|_d|_ d|_ d|_ t j |_t j|_d|_dS)NFr)rfailureserrorstestsRunskippedexpectedFailuresunexpectedSuccesses shouldStopbuffer tb_locals_stdout_buffer_stderr_buffersysstdout_original_stdoutstderr_original_stderr _mirrorOutput)rstreamZ descriptions verbosityr r r __init__&szTestResult.__init__cCsdS)Nr )rr r r printErrors7szTestResult.printErrorscCs |jd7_d|_|jdS)NrF)rr _setupStdout)rtestr r r startTest:szTestResult.startTestcCs8|jr4|jdkr$tj|_tj|_|jt_|jt_dS)N)rrioStringIOrrrr)rr r r r%@s    zTestResult._setupStdoutcCsdS)Nr )rr r r startTestRunHszTestResult.startTestRuncCs|jd|_dS)NF)_restoreStdoutr )rr&r r r stopTestNszTestResult.stopTestcCs|jr|jrltjj}tjj}|rF|jds6|d7}|jjt ||rl|jds\|d7}|j jt ||jt_|j t_|j j d|j j|jj d|jjdS)N r)rr rrgetvaluerendswithrwrite STDOUT_LINEr STDERR_LINErseektruncater)routputerrorr r r r+Ss$       zTestResult._restoreStdoutcCsdS)Nr )rr r r stopTestRunhszTestResult.stopTestRuncCs"|jj||j||fd|_dS)NT)rappend_exc_info_to_stringr )rr&errr r r addErrornszTestResult.addErrorcCs"|jj||j||fd|_dS)NT)rr8r9r )rr&r:r r r addFailurevszTestResult.addFailurecCsZ|dk rVt|ddr|jt|d|jr4|j}n|j}|j||j||fd|_dS)NrFrT) rr issubclassfailureExceptionrrr8r9r )rr&Zsubtestr:rr r r addSubTest}s zTestResult.addSubTestcCsdS)Nr )rr&r r r addSuccessszTestResult.addSuccesscCs|jj||fdS)N)rr8)rr&reasonr r r addSkipszTestResult.addSkipcCs|jj||j||fdS)N)rr8r9)rr&r:r r r addExpectedFailureszTestResult.addExpectedFailurecCs|jj|dS)N)rr8)rr&r r r addUnexpectedSuccessszTestResult.addUnexpectedSuccesscCs>t|jt|jkodkno_count_relevant_tb_levels tracebackTracebackExceptionrlistformatrrrr.rr/r8r1r2join) rr:r&exctypevaluetblengthZtb_eZmsgLinesr5r6r r r r9s*         zTestResult._exc_info_to_stringcCs d|jjkS)N __unittest)tb_frame f_globals)rrUr r r rKsz TestResult._is_relevant_tb_levelcCs,d}x"|r&|j| r&|d7}|j}qW|S)Nrr)rKrL)rrUrVr r r rMs  z$TestResult._count_relevant_tb_levelscCs&dtj|j|jt|jt|jfS)Nz!<%s run=%i errors=%i failures=%i>)rZstrclass __class__rrErr)rr r r __repr__szTestResult.__repr__)NNN)__name__ __module__ __qualname__Z_previousTestClassZ_testRunEnteredZ_moduleSetUpFailedr#r$r'r%r*r,r+r7rr;r<r?r@rBrCrDrGrr9rKrMr[r r r r rs0      r) r(rrNrJr functoolsrrWrr1r2objectrr r r r s