Viewing File: /opt/alt/python35/lib64/python3.5/__pycache__/doctest.cpython-35.opt-2.pyc



]d!@s$dZddddddddd	d
ddd
ddddddddddddddddddd d!g!Zd"d#lZd"d#lZd"d#lZd"d#lZd"d#lZd"d#lZd"d#lZd"d#l	Z	d"d#l
Z
d"d#lZd"d#lZd"d$l
mZd"d%lmZed&d'ZiZd(dZedZedZedZedZedZedZeeBeBeBeBeBZed	Zed
ZedZedZedZeeBeBeBeBZ d)Z!d*Z"d+d,Z#d-d.d/Z$d0d1Z%d2d3d4Z&d5d6Z'Gd7d8d8eZ(d9d:Z)d;d<Z*d=d>Z+Gd?d@d@ej,Z-dAdBZ.GdCddZ/GdDddZ0GdEddZ1GdFddZ2GdGddZ3GdHddZ4GdIdde5Z6GdJdde5Z7GdKdde3Z8d#a9d#d#d#d#dLd"d#dMdMdNd	Z:dLd#d#d#d#dLd"d#dMe1d#dOdZ;dMdPd#d"dQdZ<d"a=dRdZ>GdSdTdTej?Z@GdUdVdVe@ZAGdWdXdXejBZCd#d#d#d#dYdZDGdZd[d[e@ZEdLd#d#e1d#d\d]ZFd^dZGd_dZHd`dZIdMd#dad ZJdMd#dbdcZKdMddd!ZLGdedfdfZMdfeMdgdhdidjdkdldmdndodpiZNdqdrZOePdskr e
jQeOd#S)tzreStructuredText enregister_optionflagDONT_ACCEPT_TRUE_FOR_1DONT_ACCEPT_BLANKLINENORMALIZE_WHITESPACEELLIPSISSKIPIGNORE_EXCEPTION_DETAILCOMPARISON_FLAGSREPORT_UDIFFREPORT_CDIFFREPORT_NDIFFREPORT_ONLY_FIRST_FAILUREREPORTING_FLAGS	FAIL_FASTExampleDocTest
DocTestParser
DocTestFinder
DocTestRunner
OutputCheckerDocTestFailureUnexpectedExceptionDebugRunnertestmodtestfilerun_docstring_examplesDocTestSuiteDocFileSuiteset_unittest_reportflagsscript_from_examples
testsource	debug_srcdebugN)StringIO)
namedtupleTestResultszfailed attemptedcCstj|dtt>S)N)OPTIONFLAGS_BY_NAME
setdefaultlen)namer+,/opt/alt/python35/lib64/python3.5/doctest.pyrsz<BLANKLINE>z...cCsRd}xEtjD]:}|j|d}|tt|kr||jO}qW|S)Nr")
__future__Zall_feature_namesgetgetattrZ
compiler_flag)globsflagsZfnameZfeaturer+r+r,_extract_future_flagssr2cCsutj|r|St|tr>t|ttdgS|dkretjtj	|j
dStddS)N*__name__z"Expected a module, string, or None)inspectismodule
isinstancestr
__import__globalslocalssysmodules	_getframe	f_globals	TypeError)moduledepthr+r+r,_normalize_modules
rDc	Cs|rt|d}t||}t|dddk	rt|jdr|jj|}|j|}|jtj	d|fSt
|d|}|j|fSWdQRXdS)N
__loader__get_data
encoding)rD_module_relative_pathr/hasattrrFrGdecodereplaceoslinesepopenread)filenamepackagemodule_relativerIZ
file_contentsfr+r+r,_load_testfilesrVcCstjd|d|S)Nz
(?m)^(?!$) )resub)sindentr+r+r,_indentsr]cCs;t}|\}}}tj|||d||jS)Nfile)r#	tracebackprint_exceptiongetvalue)exc_infoZexcoutexc_typeexc_valexc_tbr+r+r,_exception_tracebacks	rfc@s+eZdZddZdddZdS)	_SpoofOutcCs3tj|}|r/|jdr/|d7}|S)NrH)r#raendswith)selfresultr+r+r,ras
z_SpoofOut.getvalueNcCs|j|tj|dS)N)seekr#truncate)risizer+r+r,rls
z_SpoofOut.truncate)r5
__module____qualname__rarlr+r+r+r,rgs	rgcCst|kr||kS|jt}dt|}}|d}|rq|j|rmt|}|d=ndS|d}|r|j|r|t|8}|d=ndS||krdSxC|D];}|j|||}|dkrdS|t|7}qWdS)Nr"Fr&Trp)ELLIPSIS_MARKERsplitr)
startswithrhfind)wantgotZwsstartposendposwr+r+r,_ellipsis_matchs0





rzcCs"|j}|rd|SdSdS)Nz# #)rstrip)liner+r+r,
_comment_line9sr~cCsdt|}}|jd}|dkr4|}|jdd|}|dkr[|}|jdd|}|dkr|d}|||S)Nr"rH:.r&)r)rtrfind)msgstartendir+r+r,_strip_exception_detailsAs
rc@sCeZdZddZdddZddZdd	ZdS)
_OutputRedirectingPdbcCs;||_d|_tjj|d|ddd|_dS)NFstdoutnosigintTr&)_OutputRedirectingPdb__out$_OutputRedirectingPdb__debugger_usedpdbPdb__init__Zuse_rawinput)rioutr+r+r,ras		z_OutputRedirectingPdb.__init__NcCs;d|_|dkr$tjj}tjj||dS)NT)rr=r?f_backrr	set_trace)riframer+r+r,ris	z_OutputRedirectingPdb.set_tracecCs|jrtjj|dS)N)rrrset_continue)rir+r+r,ros	z"_OutputRedirectingPdb.set_continuecGs=tj}|jt_ztjj||SWd|t_XdS)N)r=rrrrtrace_dispatch)riargssave_stdoutr+r+r,rus
	z$_OutputRedirectingPdb.trace_dispatch)r5rnrorrrrr+r+r+r,r[srcCstj|std||jdr:tdt|dretjj|j	d}nv|j
dkrttj
dkrtj
ddkrtjjtj
dd}qtj}ntd|j
tjj||jdS)	NzExpected a module: %r/z1Module-relative files may not have absolute paths__file__r"__main__zBCan't resolve paths relative to the module %r (it has no __file__))r6r7rArs
ValueErrorrKrNpathrrrr5r)r=argvcurdirjoin)rBrZbasedirr+r+r,rJs( 
rJc@s@eZdZddddddZddZddZdS)	rNr"cCs|jds|d7}|r9|jdr9|d7}|dk	r_|jdr_|d7}||_||_||_||_|dkri}||_||_dS)NrH)rhsourcerulinenor\optionsexc_msg)rirrurrr\rr+r+r,rs


					zExample.__init__cCst|t|k	rtS|j|jko|j|jko|j|jko|j|jko|j|jko|j|jkS)N)typeNotImplementedrrurr\rr)riotherr+r+r,__eq__szExample.__eq__cCs(t|j|j|j|j|jfS)N)hashrrurr\r)rir+r+r,__hash__szExample.__hash__)r5rnrorrrr+r+r+r,rs#	c@sLeZdZddZddZddZddZd	d
ZdS)rcCs@||_||_|j|_||_||_||_dS)N)examples	docstringcopyr0r*rRr)rirr0r*rRrrr+r+r,rs				zDocTest.__init__cCsut|jdkrd}n1t|jdkr<d}ndt|j}d|jj|j|j|j|fS)Nr"zno examplesr&z	1 examplez%d examplesz<%s %s from %s:%s (%s)>)r)r	__class__r5r*rRr)rirr+r+r,__repr__s			zDocTest.__repr__cCst|t|k	rtS|j|jko|j|jko|j|jko|j|jko|j|jko|j|jkS)N)rrrrr0r*rRr)rirr+r+r,rszDocTest.__eq__cCs"t|j|j|j|jfS)N)rrr*rRr)rir+r+r,r%szDocTest.__hash__cCsSt|tstS|j|j|jt|f|j|j|jt|fkS)N)r8rrr*rRrid)rirr+r+r,__lt__)szDocTest.__lt__N)r5rnrorrrrrr+r+r+r,rs
c@seZdZejdejejBZejdejejBejBZ	ejdj
ZdddZddZ
dd	d
ZddZejd
ejZddZejdejZddZddZddZdS)ra
        # Source consists of a PS1 line followed by zero or more PS2 lines.
        (?P<source>
            (?:^(?P<indent> [ ]*) >>>    .*)    # PS1 line
            (?:\n           [ ]*  \.\.\. .*)*)  # PS2 lines
        \n?
        # Want consists of any non-blank lines that do not start with PS1.
        (?P<want> (?:(?![ ]*$)    # Not a blank line
                     (?![ ]*>>>)  # Not a line starting with PS1
                     .+$\n?       # But any other line
                  )*)
        a
        # Grab the traceback header.  Different versions of Python have
        # said different things on the first traceback line.
        ^(?P<hdr> Traceback\ \(
            (?: most\ recent\ call\ last
            |   innermost\ last
            ) \) :
        )
        \s* $                # toss trailing whitespace on the header.
        (?P<stack> .*?)      # don't blink: absorb stuff until...
        ^ (?P<msg> \w+ .*)   #     a line *starts* with alphanum.
        z^[ ]*(#.*)?$z<string>c
sw|j}|j|dkrRdjfdd|jdD}g}d\}}x|jj|D]}|j|||j||jd||j7}|j	|||\}}}	}
|j
|s'|jt||	|
d|dt|j
dd|||jd|j|j7}|j}qwW|j||d|S)	Nr"rHcs g|]}|dqS)Nr+).0l)
min_indentr+r,
<listcomp>ps	z'DocTestParser.parse.<locals>.<listcomp>rr\r)r"r")
expandtabs_min_indentrrr_EXAMPLE_REfinditerappendrcount_parse_example_IS_BLANK_OR_COMMENTrr)groupr)ristringr*outputZcharnormrrrurr+)rr,parseds&+!
%zDocTestParser.parsecCs%t|j|||||||S)N)rget_examples)rirr0r*rRrr+r+r,get_doctests	zDocTestParser.get_doctestcCsdd|j||DS)NcSs%g|]}t|tr|qSr+)r8r)rxr+r+r,rs	z.DocTestParser.get_examples.<locals>.<listcomp>)r)rirr*r+r+r,rszDocTestParser.get_examplesc
sut|jd|jdjd}|j||||j|dddd||djfdd|D}|jd	}|jd}t|dkrtjd
|d
r|d=|j|d||t|djfdd|D}|jj|}|rJ|jd}nd}|j	|||}	||	||fS)Nr\rrHr&rXrcs$g|]}|ddqS)rWNr+)rsl)r\r+r,rs	z0DocTestParser._parse_example.<locals>.<listcomp>ruz *$cs g|]}|dqS)Nr+)rZwl)r\r+r,rs	rrprp)
r)rrr_check_prompt_blank
_check_prefixrrYmatch
_EXCEPTION_RE
_find_options)
rirr*rsource_linesrru
want_linesrrr+)r\r,rs$("("zDocTestParser._parse_examplez#\s*doctest:\s*([^\n\'"]*)$c	Csi}x|jj|D]}|jdjddj}xy|D]q}|ddkss|ddtkrtd|d||ft|dd}|ddk||<qGWqW|r|j|rtd|||f|S)	Nr&,rXr"z+-z7line %r of the doctest for %s has an invalid option: %r+zSline %r of the doctest for %s has an option directive on a line with no example: %r)_OPTION_DIRECTIVE_RErrrMrrr'rr)	rirr*rrroption_stringsoptionflagr+r+r,rs!
zDocTestParser._find_optionsz
^([ ]*)(?=\S)cCsCdd|jj|D}t|dkr;t|SdSdS)NcSsg|]}t|qSr+)r))rr\r+r+r,rs	z-DocTestParser._min_indent.<locals>.<listcomp>r")
_INDENT_REfindallr)min)rir[indentsr+r+r,rs
zDocTestParser._min_indentc	Cs}xvt|D]h\}}t||dkr
||ddkr
td||d||||d|fq
WdS)NrWrErXz8line %r of the docstring for %s lacks blank after %s: %rr&)	enumerater)r)rilinesr\r*rrr}r+r+r,rs
*z!DocTestParser._check_prompt_blankcCsXxQt|D]C\}}|r
|j|r
td||d||fq
WdS)NzGline %r of the docstring for %s has inconsistent leading whitespace: %rr&)rrsr)rirprefixr*rrr}r+r+r,rszDocTestParser._check_prefixN)r5rnrorYcompile	MULTILINEVERBOSErDOTALLrrrrrrrrrrrrrr+r+r+r,r4s 	'3	c@sseZdZdeddddZddddddZdd	Zd
dZdd
ZddZ	dS)rFTcCs(||_||_||_||_dS)N)_parser_verbose_recurse_exclude_empty)riverboseparserrecurse
exclude_emptyr+r+r,r(s			zDocTestFinder.__init__Nc	Cs|dkrCt|dd}|dkrCtdt|f|dkrXd}n|dkrstj|}ytj|}Wntk
rd}YnX|stj|}|d|dddksd}|dkrd}n?|dk	rtj	||j
}ntj	|}|s.d}|dkra|dkrOi}qm|j
j}n|j}|dk	r|j|d|krd|d<g}|j
||||||i|j|S)	Nr5zJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rFr"r3z<]>r)r/rrr6	getmoduleZ
getsourcefilerAZgetfile	linecachegetlines__dict__rupdate_findsort)	riobjr*rBr0
extraglobsr^rtestsr+r+r,rt>sJ$	
		


zDocTestFinder.findcCs|dkrdStj|dk	r8|tj|kStj|rW|j|jkStj|rt|dr|jj}nt|dr|j}ndS|j	|kStj
|r|j	|jkSt|dr|j	|jkSt|trdSt
ddS)NT__objclass__rnz"object must be a class or function)r6r
isfunctionr__globals__ZismethoddescriptorrKrrnr5isclassr8propertyr)rirBobjectZobj_modr+r+r,_from_modules(
zDocTestFinder._from_modulec	Cs|jrtd|t||kr-dSd|t|<|j|||||}|dk	rq|j|tj|r|jrx|jj	D]t\}	}
d||	f}	tj
tj|
stj|
r|j
||
r|j||
|	||||qWtj|r|jrxt|dij	D]\}	}
t|	tsvtdt|	ftj
|
ptj|
ptj|
pt|
tstdt|
fd||	f}	|j||
|	||||qBWtj|r|jrx|jj	D]\}	}
t|
trPt||	}
t|
trqt||	j}
tj
|
stj|
st|
tr&|j
||
r&d||	f}	|j||
|	||||q&WdS)NzFinding tests in %sr&z%s.%s__test__z5DocTestFinder.find: __test__ keys must be strings: %rz`DocTestFinder.find: __test__ values must be strings, functions, methods, classes, or modules: %rz%s.__test__.%s)rprintr	_get_testrr6r7rritemsZ	isroutineZunwraprrrr/r8r9rrstaticmethodclassmethod__func__r)rirrr*rBrr0seentestZvalnamevalr+r+r,rsP	
%zDocTestFinder._findc	Cst|tr|}nay@|jdkr3d}n$|j}t|tsWt|}Wnttfk
rxd}YnX|j||}|jr|rdS|dkrd}n;t|d|j}|dddkr|dd}|j	j
|||||S)NrrrWz.pycr&rp)r8r9__doc__rAAttributeError_find_linenorr/r5rr)	rirr*rBr0rrrrRr+r+r,rs(				zDocTestFinder._get_testcCs{d}tj|rd}tj|r|dkr:dStjdt|dd}x0t|D]"\}}|j|rf|}PqfWtj|r|j	}tj
|r|j}tj|r|j
}tj|r|j}tj|rt|ddd}|dk	rw|dkr1|dStjd}x4t|t|D]}|j||rV|SqVWdS)Nr"z^\s*class\s*%s\br5-co_firstlinenor&z(^|.*:)\s*\w*("|'))r6r7rrYrr/rrZismethodrr__code__Zistracebacktb_frameZisframef_codeZiscoderanger))rirrrpatrr}r+r+r,r$s<					zDocTestFinder._find_lineno)
r5rnrorrrtrrrrr+r+r+r,rs		f?%c@seZdZddZdddddZddZd	d
ZddZd
dZddZ	ddZ
ddZej
dZdddZdddddZdddZddZdS)rr4FNr"cCss|pt|_|dkr-dtjk}||_||_||_d|_d|_i|_	t
|_dS)Nz-vr")r_checkerr=rroptionflagsoriginal_optionflagstriesfailures_name2ftrg_fakeout)richeckerrrr+r+r,rs						zDocTestRunner.__init__cCs\|jrX|jr=|dt|jdt|jn|dt|jddS)NzTrying:
zExpecting:
zExpecting nothing
)rrur]r)rirrexampler+r+r,report_starts		(zDocTestRunner.report_startcCs|jr|ddS)Nzok
)r)rirrrrvr+r+r,report_successs	zDocTestRunner.report_successcCs3||j|||jj|||jdS)N)_failure_headerroutput_differencer)rirrrrvr+r+r,report_failureszDocTestRunner.report_failurecCs.||j||dtt|dS)NzException raised:
)rr]rf)rirrrrbr+r+r,report_unexpected_exceptionsz)DocTestRunner.report_unexpected_exceptioncCs|jg}|jrs|jdk	rJ|jdk	rJ|j|jd}nd}|jd|j||jfn!|jd|jd|jf|jd|j}|jt|dj|S)Nr&?zFile "%s", line %s, in %szLine %s, in %szFailed example:rH)DIVIDERrRrrr*rr]r)rirrrrrr+r+r,rs		!
	zDocTestRunner._failure_headercCsHd}}|j}td\}}}	|jj}
xt|jD]\}}|jt@of|dk}
||_|jrxE|jjD]4\}}|r|j|O_q|j|M_qW|jt	@rqD|d7}|
s|j
|||d|j|f}y<tt
|j|d|d|j|jjd}Wn5tk
r\Yn!tj}|jjYnX|jj}|jjd|}|dkr|
|j||jrr|}ntj|ddd}|
s|t|7}|jdkr|	}nX|
|j||jr;|}n7|jt@rr|
t|jt||jrr|}||kr|
s|j||||nj||kr|
s|j |||||d7}n5||	kr|
s|j!|||||d7}n|rD|jt"@rDPqDW||_|j#|||t$||S)Nr"rEr&z<doctest %s[%d]>Zsingler3rp)%rrrcheck_outputrrrrrrrr*execrrr0debuggerrKeyboardInterruptr=rbrrarlrur_format_exception_onlyrfrrrrrrr_DocTestRunner__record_outcomer%)rircompileflagsrrrrSUCCESSFAILUREZBOOMcheck
examplenumrquietZ
optionflagrrR	exceptionrvZoutcomerr+r+r,Z__runs
	
		




			
	

	zDocTestRunner.__runcCs^|jj|jd\}}||||f|j|j<|j|7_|j|7_dS)Nr")r"r")rr.r*rr)rirrUtf2t2r+r+r,Z__record_outcomelszDocTestRunner.__record_outcomez.<doctest (?P<name>.+)\[(?P<examplenum>\d+)\]>$cCsy|jj|}|re|jd|jjkre|jjt|jd}|jjddS|j	||SdS)Nr*r)keependsT)
%_DocTestRunner__LINECACHE_FILENAME_RErrrr*rintr
splitlinessave_linecache_getlines)rirRmodule_globalsrrr+r+r,Z__patched_linecache_getlinesys
!z*DocTestRunner.__patched_linecache_getlinesTc	su||_|dkr$t|j}tj|dkrjdks`jdkrlj}nfdd}|jt_tj	}t
j}t|_
|j
j|j
jt
_tj|_|jt_tj}tjt_z|j|||SWdt_|t
_tj||jt_|t_|rp|jjddl}d|_XdS)Nzutf-8cs,t|jd}j|dS)Nbackslashreplace)r9encodewrite)r[)rIrr+r,rszDocTestRunner.run.<locals>.outr")rr2r0r=rrIlowerr7rgettracerrrr!resetrrr3*_DocTestRunner__patched_linecache_getlinesdisplayhook__displayhook___DocTestRunner__runsettraceclearbuiltins_)	rirr%rclear_globsZ
save_traceZsave_set_traceZsave_displayhookrAr+)rIrr,runs<				
			
	
zDocTestRunner.runc
Cs$|dkr|j}g}g}g}d}}x|jjD]w}|\}\}	}
||
7}||	7}|
dkr|j|qA|	dkr|j||
fqA|j|qAW|rQ|rtt|d|jx|D]}td|qW|rQtt|d|jx(|D] \}}td||fq-W|rt|jtt|d|jx1|D])\}\}	}
td|	|
|fqW|rt|dt|jd	t||d
|d|rtd|d
n|rtdt||S)Nr"zitems had no tests:z   zitems passed all tests:z %3d tests in %szitems had failures:z %3d of %3d in %sztests inzitems.z
passed andzfailed.z***Test Failed***z	failures.zTest passed.)	rrrrrr)rrr%)
rirZnotestsZpassedZfailedZtotaltZtotalfrr*rUr,thingrr+r+r,	summarizesP	








zDocTestRunner.summarizecCss|j}xc|jjD]R\}\}}||kr[||\}}||}||}||f||<qWdS)N)rr)rirdr*rUr,r-r.r+r+r,merges	"

zDocTestRunner.merge)r5rnrorrrrrrrr>r$rYrr0r;rDrFrHr+r+r+r,rXs:
$
}
I9c@s@eZdZddZddZddZddZd	S)
rcCst|jdddS)NASCIIr5)r9r6)rir[r+r+r,_toAsciiszOutputChecker._toAsciicCs|j|}|j|}||kr.dS|t@sd||fdkrNdS||fdkrddS|t@stjdtjtd|}tjdd|}||krdS|t@rd	j|j	}d	j|j	}||krdS|t
@rt||rdSd
S)
NTTrue
1
False
0
z(?m)^%s\s*?$rz
(?m)^\s*?$rXF)rKrL)rMrN)rJrrrYrZescapeBLANKLINE_MARKERrrrrrrz)rirurvrr+r+r,rs0



zOutputChecker.check_outputcCsL|ttBtB@sdS|t@r$dS|jddkoK|jddkS)NFTrHr3)r	r
rr)rirurvrr+r+r,_do_a_fancy_diff]s
zOutputChecker._do_a_fancy_diffc
Cs|j}|t@s(tjdt|}|j|||rQ|jdd}|jdd}|t@rtj	||dd}t
|dd}d}n|t@rtj||dd}t
|dd}d}n@|t
@r#tjdtj}	t
|	j||}d	}nd
d|D}d|td
j|S|rw|rwdt|t|fS|rdt|S|rdt|SdSdS)Nz(?m)^[ ]*(?=
)r/Tnr3z#unified diff with -expected +actualz-context diff with expected followed by actualZcharjunkzndiff with -expected +actualcSs g|]}|jdqS)rH)r|)rr}r+r+r,rs	z3OutputChecker.output_difference.<locals>.<listcomp>zDifferences (%s):
rzExpected:
%sGot:
%szExpected:
%sGot nothing
zExpected nothing
Got:
%szExpected nothing
Got nothing
)rurrYrZrPrQr2r	difflibZunified_difflistr
Zcontext_diffrZDifferZIS_CHARACTER_JUNKZcomparer]r)
rirrvrrurZ	got_linesZdiffkindZenginer+r+r,rts6	

	
	
	zOutputChecker.output_differenceN)r5rnrorJrrQrr+r+r+r,rs?c@s(eZdZddZddZdS)rcCs||_||_||_dS)N)rrrv)rirrrvr+r+r,rs		zDocTestFailure.__init__cCs
t|jS)N)r9r)rir+r+r,__str__szDocTestFailure.__str__N)r5rnrorrVr+r+r+r,rsc@s(eZdZddZddZdS)rcCs||_||_||_dS)N)rrrb)rirrrbr+r+r,rs		zUnexpectedException.__init__cCs
t|jS)N)r9r)rir+r+r,rVszUnexpectedException.__str__N)r5rnrorrVr+r+r+r,rsc@s=eZdZdddddZddZddZdS)	rNTcCs2tj||||d}|r.|jj|S)NF)rrDr0r@)rirr%rrCrr+r+r,rD%s
zDebugRunner.runcCst|||dS)N)r)rirrrrbr+r+r,r+sz'DebugRunner.report_unexpected_exceptioncCst|||dS)N)r)rirrrrvr+r+r,r.szDebugRunner.report_failure)r5rnrorDrrr+r+r+r,rs[TFc	Cs|dkrtjjd}tj|s@td|f|dkrU|j}td|}	|rtd|d|}
nt	d|d|}
x3|	j
||d|d|D]}|
j|qW|r|
jt
dkr|
a
n
t
j|
t|
j|
jS)Nrztestmod: module required; %rrrrr0r)r=r>r.r6r7rAr5rrrrtrDrFmasterrHr%rr)rr*r0rreportrrraise_on_errorrfinderrunnerrr+r+r,r:s$E	%
	
cCsH|r|rtdt||||p.d\}}|dkrXtjj|}|dkrmi}n|j}|dk	r|j|d|krd|d<|	rtd|d|}
ntd|d|}
|
j	||||d}|
j
||r|
jtdkr(|
an
tj
|
t|
j|
jS)Nz8Package may only be specified for module-relative paths.zutf-8r5rrrr")rrVrNrbasenamerrrrrrDrFrXrHr%rr)rRrTr*rSr0rrYrrrZrrItextr\rr+r+r,rs0R
	



	
ZNoNamec	Csdtd|dd}td|d|}x3|j||d|D]}|j|d|qCWdS)NrrFrr0r%)rrrtrD)	rUr0rr*r%rr[r\rr+r+r,rscCs/|t@|krtd|t}|a|S)NzOnly reporting flags allowed)r
r_unittest_reportflags)r1oldr+r+r,r:s
c@seZdZddddddZddZddZd	d
ZddZd
dZddZ	ddZ
ddZddZeZ
ddZdS)DocTestCaser"NcCsAtjj|||_||_||_||_||_dS)N)unittestTestCaser_dt_optionflags_dt_checker_dt_test	_dt_setUp_dt_tearDown)rirrsetUptearDownrr+r+r,r`s				zDocTestCase.__init__cCs)|j}|jdk	r%|j|dS)N)rfrg)rirr+r+r,rijs	zDocTestCase.setUpcCs6|j}|jdk	r%|j||jjdS)N)rfrhr0r@)rirr+r+r,rjps	
zDocTestCase.tearDowncCs|j}tj}t}|j}|t@s8|tO}td|d|jdd}z5dd|_	|j
|d|jdd\}}Wd|t_X|r|j|j
|jdS)	NrrrFrr
rrC)rfr=rr#rdr
r_rrerrDr7ZfailureExceptionformat_failurera)rirr`newrr\rrr+r+r,runTestxs				


"
zDocTestCase.runTestcCsp|j}|jdkr!d}n
d|j}dj|jjddd}d|j|j|||fS)Nzunknown line numberz%srr&z:Failed doctest test for %s
  File "%s", line %s, in %s

%srp)rfrrr*rrrR)rierrrrZlnamer+r+r,rks		
%zDocTestCase.format_failurecCsO|jtd|jd|jdd}|j|jdd|jdS)NrrrFrC)rirrdrerDrfrj)rir\r+r+r,r!s
B
zDocTestCase.debugcCs
|jjS)N)rfr*)rir+r+r,rszDocTestCase.idcCstt|t|k	rtS|j|jkos|j|jkos|j|jkos|j|jkos|j|jkS)N)rrrfrdrgrhre)rirr+r+r,rszDocTestCase.__eq__cCs"t|j|j|j|jfS)N)rrdrgrhre)rir+r+r,rszDocTestCase.__hash__cCs:|jjjd}d|ddj|ddfS)Nrz%s (%s)r&rprp)rfr*rrr)rir*r+r+r,rszDocTestCase.__repr__cCsd|jjS)Nz	Doctest: )rfr*)rir+r+r,shortDescriptionszDocTestCase.shortDescription)r5rnrorrirjrmrkr!rrrrrVror+r+r+r,ra^s		H
rac@sFeZdZddZddZddZddZeZd	S)
SkipDocTestCasecCs||_tj|ddS)N)rBrar)rirBr+r+r,rs	zSkipDocTestCase.__init__cCs|jddS)Nz-DocTestSuite will not work with -O2 and above)ZskipTest)rir+r+r,ri	szSkipDocTestCase.setUpcCsdS)Nr+)rir+r+r,	test_skip	szSkipDocTestCase.test_skipcCsd|jjS)NzSkipping tests from %s)rBr5)rir+r+r,ro		sz SkipDocTestCase.shortDescriptionN)r5rnrorrirqrorVr+r+r+r,rps
rpc@seZdZddZdS)
_DocTestSuitecCsdS)Nr+)riindexr+r+r,_removeTestAtIndex	sz _DocTestSuite._removeTestAtIndexN)r5rnrortr+r+r+r,rr	srrc	Ks|dkrt}t|}|j|d|d|}|rutjjdkrut}|jt||S|j	t}x}|D]u}t
|jdkrq|js|j
}|dddkr|dd	}||_|jt||qW|S)
Nr0rr3r"rWz.pycr&rrp)rrDrtr=r1optimizerraddTestrprr)rrRrra)	rBr0rZtest_finderrrsuiterrRr+r+r,r	s(%		
	
			c@s:eZdZddZddZeZddZdS)DocFileCasecCsdj|jjjdS)NrBr)rrfr*rr)rir+r+r,rW	szDocFileCase.idcCs
|jjS)N)rfrR)rir+r+r,rZ	szDocFileCase.__repr__cCsd|jj|jj|fS)Nz2Failed doctest test for %s
  File "%s", line 0

%s)rfr*rR)rirnr+r+r,rk^	szDocFileCase.format_failureN)r5rnrorrrVrkr+r+r+r,rxU	srxc
Ks|dkri}n|j}|r:|r:tdt||||pOd\}}d|krq||d<tjj|}|j||||d}	t|	|S)Nz8Package may only be specified for module-relative paths.zutf-8rr")rrrVrNrr]rrx)
rrTrSr0rrIrdocr*rr+r+r,DocFileTestc	s	

rzcOs_t}|jddr4t|jd|d<x$|D]}|jt||q;W|S)NrTTrS)rrr.rDrvrz)pathskwrwrr+r+r,r}	s8	
cCs!g}xtj|D]}t|tr|j|jdd	|j}|r|jd|dd|jddd
D7}q|dd|jdddD7}qWx$|r|ddkr|jqWx'|r|ddkr|jdqWdj	|dS)
Nr&z# Expected:cSsg|]}d|qS)z## r+)rrr+r+r,r	
s	z(script_from_examples.<locals>.<listcomp>rHcSsg|]}t|qSr+)r~)rrr+r+r,r
s	r{r"rprprprp)
rrr8rrrrurrpopr)r[rZpiecerur+r+r,r	s:	
-"csit|}tj|}fdd|D}|sLtd|d}t|j}|S)Ncs%g|]}|jkr|qSr+)r*)rr,)r*r+r,r!
s	ztestsource.<locals>.<listcomp>znot found in testsr")rDrrtrrr)rBr*rrtestsrcr+)r*r,r
s
cCs t|}t|||dS)N)rdebug_script)srcpmr0r~r+r+r,r (
sc
Csddl}|r!|j}ni}|ryt|||Wqttjd|jdd}|j|jdtjdYqXn#|jddj	d|||dS)Nr"r&rTr3zexec(%r))
rrr rr=rbrr:ZinteractionrD)rrr0rpr+r+r,r-
s
"rcCs2t|}t||}t|||jdS)N)rDrrr)rBr*rr~r+r+r,r!A
sc@s4eZdZddZddZddZdS)
_TestClasscCs
||_dS)N)r)rirr+r+r,r]
sz_TestClass.__init__cCs|jd|_|S)Nr3)r)rir+r+r,squareg
sz_TestClass.squarecCs|jS)N)r)rir+r+r,r.q
sz_TestClass.getN)r5rnrorrr.r+r+r+r,rO
s

rrz
                      Example of a string object, searched as-is.
                      >>> x = 1; y = 2
                      >>> x + y, x * y
                      (3, 2)
                      zbool-int equivalencea
                                    In 2.2, boolean expressions displayed
                                    0 or 1.  By default, we still accept
                                    them.  This can be disabled by passing
                                    DONT_ACCEPT_TRUE_FOR_1 to the new
                                    optionflags argument.
                                    >>> 4 == 4
                                    1
                                    >>> 4 == 4
                                    True
                                    >>> 4 > 4
                                    0
                                    >>> 4 > 4
                                    False
                                    zblank linesz
                Blank lines can be marked with <BLANKLINE>:
                    >>> print('foo\n\nbar\n')
                    foo
                    <BLANKLINE>
                    bar
                    <BLANKLINE>
            Zellipsisz
                If the ellipsis flag is used, then '...' can be used to
                elide substrings in the desired output:
                    >>> print(list(range(1000))) #doctest: +ELLIPSIS
                    [0, 1, 2, ..., 999]
            zwhitespace normalizationa
                If the whitespace normalization flag is used, then
                differences in whitespace are ignored.
                    >>> print(list(range(30))) #doctest: +NORMALIZE_WHITESPACE
                    [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                     15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
                     27, 28, 29]
            cCstjdd}|jddddddd	d
|jdddd
dtjdgd	d|jddddd	d|jdddd	d|j}|j}|j}d}x|jD]}|t|O}qW|j	r|t
O}x|D]}|jdrxtj
j|\}}tj
jd|t|dd}tj
d=t|d|d|\}	}
n$t|ddd|d|\}	}
|	rdSqWdS)Ndescriptionzdoctest runnerz-vz	--verboseaction
store_truedefaultFhelpz'print very verbose output for all testsz-oz--optionrchoiceszqspecify a doctest option flag to apply to the test run; may be specified more than once to apply multiple optionsz-fz--fail-fastzystop running tests after first failure (this is a shorthand for -o FAIL_FAST, and is in addition to any other -o options)r^nargsrz file containing the tests to runr"z.pyrErrrTr&)argparseArgumentParseradd_argumentr'keys
parse_argsr^rrZ	fail_fastrrhrNrrrr=insertr:rr)rrZ	testfilesrrrrRdirnamerrrBr+r+r,_test
s<			


!rr)RZ
__docformat____all__r-rrSr6rrNrrYr=r_rbior#collectionsr$r%r'rrrrrrrrr	r
rrrr
rPrqr2rDrVr]rfrgrzr~rrrrJrrrrrr	ExceptionrrrrXrrrr_rrcrarpZ	TestSuiterrrrxrzrrrr rr!rrrr5exitr+r+r+r,<module>0s	1%%DK:n	f	x$@	IR,	+
Back to Directory File Manager