Hacked By AnonymousFox

Current Path : /opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/__pycache__/doctest.cpython-37.opt-2.pyc

B

YI~dp��!@spdZddddddddd	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m
Z
d"d%lmZed&d'�ZiZd(d�Zed�Zed�Zed�Zed�Zed�Zed�ZeeBeBeBeBeBZed	�Zed
�Zed�Zed�Zed�ZeeBeBeBeBZd)Z d*Z!d+d,�Z"drd.d/�Z#d0d1�Z$d2d3�Z%dsd5d6�Z&d7d8�Z'Gd9d:�d:e
�Z(d;d<�Z)d=d>�Z*d?d@�Z+GdAdB�dBej,�Z-dCdD�Z.GdEd�d�Z/GdFd�d�Z0GdGd�d�Z1GdHd�d�Z2GdId�d�Z3GdJd�d�Z4GdKd�de5�Z6GdLd�de5�Z7GdMd�de3�Z8d#a9dtdPd�Z:dNd#d#d#d#dNd"d#dOe1�d#fdQd�Z;dudSd�Z<d"a=dTd�Z>GdUdV�dVej?�Z@GdWdX�dXe@�ZAGdYdZ�dZejB�ZCdvd[d�ZDGd\d]�d]e@�ZEdNd#d#e1�d#fd^d_�ZFd`d�ZGdad�ZHdbd�ZIdwdcd �ZJdxddde�ZKdydfd!�ZLGdgdh�dh�ZMeMdidjdkdldmdn�ZNdodp�ZOePdqk�rle	�QeO��d#S)zzreStructuredText en�register_optionflag�DONT_ACCEPT_TRUE_FOR_1�DONT_ACCEPT_BLANKLINE�NORMALIZE_WHITESPACE�ELLIPSIS�SKIP�IGNORE_EXCEPTION_DETAIL�COMPARISON_FLAGS�REPORT_UDIFF�REPORT_CDIFF�REPORT_NDIFF�REPORT_ONLY_FIRST_FAILURE�REPORTING_FLAGS�	FAIL_FAST�Example�DocTest�
DocTestParser�
DocTestFinder�
DocTestRunner�
OutputChecker�DocTestFailure�UnexpectedException�DebugRunner�testmod�testfile�run_docstring_examples�DocTestSuite�DocFileSuite�set_unittest_reportflags�script_from_examples�
testsource�	debug_src�debug�N)�StringIO)�
namedtuple�TestResultszfailed attemptedcCst�|dtt�>�S)N�)�OPTIONFLAGS_BY_NAME�
setdefault�len)�name�r+�,/opt/alt/python37/lib64/python3.7/doctest.pyr�sz<BLANKLINE>z...cCs<d}x2tjD](}|�|d�}|tt|�kr||jO}qW|S)Nr")�
__future__Zall_feature_names�get�getattrZ
compiler_flag)�globs�flagsZfnameZfeaturer+r+r,�_extract_future_flags�sr2�cCsVt�|�r|St|t�r,t|t�t�dg�S|dkrJtjt�	|�j
dStd��dS)N�*�__name__z"Expected a module, string, or None)�inspect�ismodule�
isinstance�str�
__import__�globals�locals�sys�modules�	_getframe�	f_globals�	TypeError)�module�depthr+r+r,�_normalize_module�s


rDcCsxdD]}|�|d�}qW|S)N)z
�
�
)�replace)�data�newliner+r+r,�_newline_convert�s
rJc	Csz|rVt|d�}t||�}t|dd�dk	rVt|jd�rV|j�|�}|�|�}t|�|fSt||d��}|�	�|fSQRXdS)N��
__loader__�get_data)�encoding)
rD�_module_relative_pathr/�hasattrrLrM�decoderJ�open�read)�filename�package�module_relativerNZ
file_contents�fr+r+r,�_load_testfile�s


rX�cCst�d|d|�S)Nz
(?m)^(?!$)� )�re�sub)�s�indentr+r+r,�_indent�sr_cCs*t�}|\}}}tj||||d�|��S)N)�file)r#�	traceback�print_exception�getvalue)�exc_infoZexcout�exc_typeZexc_valZexc_tbr+r+r,�_exception_traceback�s
rfc@seZdZdd�Zddd�ZdS)�	_SpoofOutcCs$t�|�}|r |�d�s |d7}|S)NrF)r#rc�endswith)�self�resultr+r+r,rcs
z_SpoofOut.getvalueNcCs|�|�t�|�dS)N)�seekr#�truncate)ri�sizer+r+r,rl	s
z_SpoofOut.truncate)N)r5�
__module__�__qualname__rcrlr+r+r+r,rg�s	rgcCs�t|kr||kS|�t�}dt|�}}|d}|rR|�|�rNt|�}|d=ndS|d}|r�|�|�r||t|�8}|d=ndS||kr�dSx2|D]*}|�|||�}|dkr�dS|t|�7}q�WdS)Nr"F���T)�ELLIPSIS_MARKER�splitr)�
startswithrh�find)�want�gotZws�startpos�endpos�wr+r+r,�_ellipsis_matchs0



rzcCs|��}|rd|SdSdS)Nz# �#)�rstrip)�liner+r+r,�
_comment_line?sr~cCshdt|�}}|�d�}|dkr$|}|�dd|�}|dkr>|}|�dd|�}|dkr\|d}|||�S)Nr"rF�:�.r&)r)rt�rfind)�msg�start�end�ir+r+r,�_strip_exception_detailsGs
r�c@s.eZdZdd�Zd
dd�Zdd�Zdd	�ZdS)�_OutputRedirectingPdbcCs(||_d|_tjj||dd�d|_dS)NFT)�stdout�nosigintr&)�_OutputRedirectingPdb__out�$_OutputRedirectingPdb__debugger_used�pdb�Pdb�__init__Zuse_rawinput)ri�outr+r+r,r�gsz_OutputRedirectingPdb.__init__NcCs*d|_|dkrt��j}tj�||�dS)NT)r�r=r?�f_backr�r��	set_trace)ri�framer+r+r,r�os
z_OutputRedirectingPdb.set_tracecCs|jrtj�|�dS)N)r�r�r��set_continue)rir+r+r,r�usz"_OutputRedirectingPdb.set_continuecGs.tj}|jt_ztjj|f|��S|t_XdS)N)r=r�r�r�r��trace_dispatch)ri�args�save_stdoutr+r+r,r�{s
z$_OutputRedirectingPdb.trace_dispatch)N)r5rnror�r�r�r�r+r+r+r,r�as
r�cCs�t�|�std|��|�d�r(td��tjj|�d��}t	|d�rXtj�|j
�d}n�|jdkr�tt
j�dkr�t
jddkr�tj�t
jd�d}q�tj}nFt	|d�r�x,|jD]"}tj�||�}tj�|�r�|Sq�Wtd	|j��tj�||�S)
NzExpected a module: %r�/z1Module-relative files may not have absolute paths�__file__r"�__main__��__path__zBCan't resolve paths relative to the module %r (it has no __file__))r6r7rArs�
ValueError�os�path�joinrrrPr�r5r)r=�argv�curdirr��exists)rBZ	test_pathZbasedirZ	directoryZfullpathr+r+r,rO�s&





rOc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rNr"cCsv|�d�s|d7}|r(|�d�s(|d7}|dk	rB|�d�sB|d7}||_||_||_||_|dkrfi}||_||_dS)NrF)rh�sourceru�linenor^�options�exc_msg)rir�rur�r�r^r�r+r+r,r��s
zExample.__init__cCs\t|�t|�k	rtS|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkS)N)�type�NotImplementedr�rur�r^r�r�)ri�otherr+r+r,�__eq__�szExample.__eq__cCst|j|j|j|j|jf�S)N)�hashr�rur�r^r�)rir+r+r,�__hash__�szExample.__hash__)Nr"r"N)r5rnror�r�r�r+r+r+r,r�s#
c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCs,||_||_|��|_||_||_||_dS)N)�examples�	docstring�copyr0r*rTr�)rir�r0r*rTr�r�r+r+r,r�s
zDocTest.__init__cCsRt|j�dkrd}n"t|j�dkr(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*rTr�)rir�r+r+r,�__repr__szDocTest.__repr__cCs\t|�t|�k	rtS|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkS)N)r�r�r�r�r0r*rTr�)rir�r+r+r,r�)szDocTest.__eq__cCst|j|j|j|jf�S)N)r�r�r*rTr�)rir+r+r,r�4szDocTest.__hash__cCs:t|t�stS|j|j|jt|�f|j|j|jt|�fkS)N)r8rr�r*rTr��id)rir�r+r+r,�__lt__8s
zDocTest.__lt__N)r5rnror�r�r�r�r�r+r+r+r,r�s
c@s�eZdZe�dejejB�Ze�dejejBejB�Z	e�d�j
Zddd�Zdd�Z
dd	d
�Zdd�Ze�d
ej�Zdd�Ze�dej�Zdd�Zdd�Zdd�ZdS)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^[ ]*(#.*)?$�<string>c
s|��}|�|���dkr8d��fdd�|�d�D��}g}d\}}x�|j�|�D]�}|�|||����||�d||���7}|�	|||�\}}}	}
|�
|�s�|�t||	|
|�t|�
d��|d��||�d|��|���7}|��}qRW|�||d��|S)Nr"rFcsg|]}|�d��qS)Nr+)�.0�l)�
min_indentr+r,�
<listcomp>sz'DocTestParser.parse.<locals>.<listcomp>)r"r"r^)r�r^r�)�
expandtabs�_min_indentr�rr�_EXAMPLE_RE�finditer�appendr��count�_parse_example�_IS_BLANK_OR_COMMENTrr)�groupr�)ri�stringr*�outputZcharnor��mr�r�rur�r+)r�r,�parsess&


zDocTestParser.parsecCst|�||�|||||�S)N)r�get_examples)rir�r0r*rTr�r+r+r,�get_doctest�s	zDocTestParser.get_doctestcCsdd�|�||�D�S)NcSsg|]}t|t�r|�qSr+)r8r)r��xr+r+r,r��sz.DocTestParser.get_examples.<locals>.<listcomp>)r�)rir�r*r+r+r,r��szDocTestParser.get_examplesc
s
t|�d���|�d��d�}|�|�||�|�|dd�d�d||�d��fdd�|D��}|�d	�}|�d�}t|�dkr�t�d
|d�r�|d=|�|d�||t|��d��fdd�|D��}|j�|�}|r�|�d
�}nd}|�	|||�}	||	||fS)Nr^r�rFr&rZr�csg|]}|�dd��qS)rYNr+)r��sl)r^r+r,r��sz0DocTestParser._parse_example.<locals>.<listcomp>ruz *$rpcsg|]}|�d��qS)Nr+)r�Zwl)r^r+r,r��sr�)
r)r�rr�_check_prompt_blank�
_check_prefixr�r[�match�
_EXCEPTION_RE�
_find_options)
rir�r*r��source_linesr�ru�
want_linesr�r�r+)r^r,r��s$ 

zDocTestParser._parse_examplez#\s*doctest:\s*([^\n\'"]*)$c	Cs�i}x�|j�|�D]z}|�d��dd���}x^|D]V}|ddksR|dd�tkrhtd|d||f��t|dd�}|ddk||<q2WqW|r�|�|�r�td|||f��|S)	Nr&�,rZr"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_REr�r�rGrrr'r�r�)	rir�r*r�r�r��option_strings�option�flagr+r+r,r��s
zDocTestParser._find_optionsz
^([ ]*)(?=\S)cCs2dd�|j�|�D�}t|�dkr*t|�SdSdS)NcSsg|]}t|��qSr+)r))r�r^r+r+r,r�
sz-DocTestParser._min_indent.<locals>.<listcomp>r")�
_INDENT_RE�findallr)�min)rir]�indentsr+r+r,r�szDocTestParser._min_indentc	Csbx\t|�D]P\}}t|�|dkr
||ddkr
td||d||||d�|f��q
WdS)NrYrKrZz8line %r of the docstring for %s lacks blank after %s: %rr&)�	enumerater)r�)ri�linesr^r*r�r�r}r+r+r,r�s
 z!DocTestParser._check_prompt_blankcCsBx<t|�D]0\}}|r
|�|�s
td||d||f��q
WdS)NzGline %r of the docstring for %s has inconsistent leading whitespace: %rr&)r�rsr�)rir��prefixr*r�r�r}r+r+r,r�szDocTestParser._check_prefixN)r�)r�)r5rnror[�compile�	MULTILINE�VERBOSEr��DOTALLr�r�r�r�r�r�r�r�r�r�r�r�r�r+r+r+r,rCs 	
'
3c@sJeZdZde�ddfdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)rFTcCs||_||_||_||_dS)N)�_parser�_verbose�_recurse�_exclude_empty)ri�verbose�parser�recurse�
exclude_emptyr+r+r,r�7szDocTestFinder.__init__Nc		CsN|dkr.t|dd�}|dkr.tdt|�f��|dkr<d}n|dkrNt�|�}yt�|�}Wntk
rtd}YndX|s�t�|�}|d|dd�dks�d}|dkr�d}n*|dk	r�t�	||j
�}n
t�	|�}|s�d}|dkr�|dkr�i}n
|j
��}n|��}|dk	�r|�|�d|k�r(d|d<g}|�
||||||i�|��|S)Nr5zJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rFr"���z<]>r�)r/r�r�r6�	getmoduleZ
getsourcefilerAZgetfile�	linecache�getlines�__dict__r��update�_find�sort)	ri�objr*rBr0�
extraglobsr`r��testsr+r+r,rtMsJ$






zDocTestFinder.findcCs�|dkrdSt�|�dk	r(|t�|�kSt�|�r>|j|jkSt�|�r|t|d�r\|jj}nt|d�rn|j}ndS|j	|kSt�
|�r�|j	|jkSt|d�r�|j	|jkSt|t�r�dSt
d��dS)NT�__objclass__rnz"object must be a class or function)r6r��
isfunctionr��__globals__ZismethoddescriptorrPr�rnr5�isclassr8�propertyr�)rirB�objectZobj_modr+r+r,�_from_module�s(








zDocTestFinder._from_modulec
Cs*|jrtd|�t|�|kr"dSd|t|�<|�|||||�}|dk	rR|�|�t�|�r�|jr�x^|j�	�D]P\}	}
d||	f}	t�
t�|
��s�t�|
�rn|�
||
�rn|�||
|	||||�qnWt�|��rv|j�rvx�t|di��	�D]�\}	}
t|	t��stdt|	�f��t�
|
��sPt�|
��sPt�|
��sPt|
t��sPtdt|
�f��d||	f}	|�||
|	||||�q�Wt�|��r&|j�r&x�|j�	�D]�\}	}
t|
t��r�t||	�}
t|
t��r�t||	�j}
t�
|
��s�t�|
��s�t|
t��r�|�
||
��r�d||	f}	|�||
|	||||��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)r��printr��	_get_testr�r6r7r�r��itemsZ	isroutineZunwrapr�r�r�r/r8r9r�r��staticmethod�classmethod�__func__r�)rir�r�r*rBr�r0�seen�testZvalname�valr+r+r,r��sP


zDocTestFinder._findc		Cs�t|t�r|}nJy,|jdkr"d}n|j}t|t�s:t|�}Wnttfk
rXd}YnX|�||�}|jrt|stdS|dkr�d}n.t|dd�p�|j}|dd�dkr�|dd�}|j	�
|||||�S)Nr�r����z.pycrp)r8r9�__doc__rA�AttributeError�_find_linenor�r/r5r�r�)	rir�r*rBr0r�r�r�rTr+r+r,r�s(




zDocTestFinder._get_testcCsd}t�|�rd}t�|�rd|dkr(dSt�dt|dd��}x$t|�D]\}}|�|�rH|}PqHWt�|�rt|j	}t�
|�r�|j}t�|�r�|j
}t�|�r�|j}t�|�r�t|dd�d}|dk	�r|dkr�|dSt�d�}x(t|t|��D]}|�||�r�|Sq�WdS)Nr"z^\s*class\s*%s\br5�-�co_firstlinenor&z(^|.*:)\s*\w*("|\'))r6r7r�r[r�r/r�r�Zismethodrr��__code__Zistraceback�tb_frameZisframe�f_codeZiscode�ranger))rir�r�r�Zpatr�r}r+r+r,r	4s<









zDocTestFinder._find_lineno)NNNN)
r5rnrorr�rtr�r�r�r	r+r+r+r,r.s	
f?&c@s�eZdZdZddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Ze�
d�Zddd�Zd dd�Zd!dd�Zdd�ZdS)"rzF**********************************************************************Nr"cCsN|pt�|_|dkrdtjk}||_||_||_d|_d|_i|_	t
�|_dS)Nz-vr")r�_checkerr=r�r��optionflags�original_optionflags�tries�failures�_name2ftrg�_fakeout)ri�checkerr�rr+r+r,r��s
zDocTestRunner.__init__cCsH|jrD|jr.|dt|j�dt|j��n|dt|j�d�dS)NzTrying:
zExpecting:
zExpecting nothing
)r�rur_r�)rir�r�exampler+r+r,�report_start�s zDocTestRunner.report_startcCs|jr|d�dS)Nzok
)r�)rir�rrrvr+r+r,�report_success�szDocTestRunner.report_successcCs&||�||�|j�|||j��dS)N)�_failure_headerr�output_differencer)rir�rrrvr+r+r,�report_failure�szDocTestRunner.report_failurecCs$||�||�dtt|���dS)NzException raised:
)rr_rf)rir�rrrdr+r+r,�report_unexpected_exception�sz)DocTestRunner.report_unexpected_exceptioncCs�|jg}|jrR|jdk	r4|jdk	r4|j|jd}nd}|�d|j||jf�n|�d|jd|jf�|�d�|j}|�t|��d�|�S)Nr&�?zFile "%s", line %s, in %szLine %s, in %szFailed example:rF)�DIVIDERrTr�r�r*r�r_r�)rirrr�r�r�r+r+r,r�s
zDocTestRunner._failure_headerc	Cs�d}}|j}td�\}}}	|jj}
�xFt|j�D�]6\}}|jt@oL|dk}
||_|jr�x:|j��D],\}}|r�|j|O_qf|j|M_qfW|jt	@r�q2|d7}|
s�|�
|||�d|j|f}y,tt
|j|d|d�|j�|j��d}Wn4tk
�r�Ynt��}|j��YnX|j��}|j�d�|}|dk�rh|
|j||j��r�|}n|tj|dd��d}|
�s�|t|�7}|jdk�r�|	}nB|
|j||j��r�|}n*|jt@�r�|
t|j�t|�|j��r�|}||k�r|
�sZ|�||||�nT||k�r0|
�s&|� ||||�|d7}n*||	k�rZ|
�sP|�!||||�|d7}n|r2|jt"@r2Pq2W||_|�#|||�t$||�S)Nr"rKr&z<doctest %s[%d]>Zsingler3rp)%rrr�check_outputr�r�rr�r�rrr*�execr�r�r0�debuggerr��KeyboardInterruptr=rdrrcrlrura�format_exception_onlyrfr�rr�rrrr�_DocTestRunner__record_outcomer%)rir�compileflagsr�rrr�SUCCESS�FAILUREZBOOMZcheck�
examplenumr�quietZ
optionflagrrTZ	exceptionrvZoutcomer�r+r+r,Z__run�s�












zDocTestRunner.__runcCsL|j�|jd�\}}||||f|j|j<|j|7_|j|7_dS)N)r"r")rr.r*rr)rirrW�t�f2�t2r+r+r,Z__record_outcome|szDocTestRunner.__record_outcomez.<doctest (?P<name>.+)\[(?P<examplenum>\d+)\]>$cCsV|j�|�}|rF|�d�|jjkrF|jjt|�d��}|jjdd�S|�	||�SdS)Nr*r*T)�keepends)
�%_DocTestRunner__LINECACHE_FILENAME_REr�r�rr*r��intr��
splitlines�save_linecache_getlines)rirT�module_globalsr�rr+r+r,Z__patched_linecache_getlines�s
z*DocTestRunner.__patched_linecache_getlinesTc		s�||_|dkrt|j�}tj�|dkrV�j��dks@���dkrH�j}n��fdd�}|jt_t�	�}t
j}t��|_
|j
��|j
jt
_tj|_|jt_tj}tjt_z|�|||�S�t_|t
_t�|�|jt_|t_|r�|j��ddl}d|_XdS)Nzutf-8cs t|��d���}��|�dS)N�backslashreplace)r9�encode�write)r])rNr�r+r,r��szDocTestRunner.run.<locals>.outr")rr2r0r=r�rN�lowerr7r�gettracer�r�r�r#�resetr�r�r3�*_DocTestRunner__patched_linecache_getlines�displayhook�__displayhook__�_DocTestRunner__run�settrace�clear�builtins�_)	rirr'r��clear_globsZ
save_traceZsave_set_traceZsave_displayhookrAr+)rNr�r,�run�s<





zDocTestRunner.runc
Cs�|dkr|j}g}g}g}d}}xd|j��D]V}|\}\}	}
||
7}||	7}|
dkrb|�|�q.|	dkrz|�||
f�q.|�|�q.W|r�|r�tt|�d�|��x|D]}td|�q�W|r�tt|�d�|��x |D]\}}td||f�q�W|�rJt|j�tt|�d�|��x(|D] \}\}	}
td|	|
|f��q&W|�rvt|dt|j�d	�t||d
|d�|�r�td|d
�n|�r�td�t||�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.)	r�rr�r�r�r)r�r r%)
rir�ZnotestsZpassedZfailedZtotaltZtotalfr�r*rWr,�thingr�r+r+r,�	summarize�sP

zDocTestRunner.summarizecCsV|j}xJ|j��D]<\}\}}||krB||\}}||}||}||f||<qWdS)N)rr�)rir��dr*rWr,r-r.r+r+r,�mergeszDocTestRunner.merge)NNr")N)NNT)N)r5rnror r�rrrrrr>r&r[r�r0r;rDrFrHr+r+r+r,rhs:
$
}



I
9c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCst|�dd�d�S)N�ASCIIr5)r9r6)rir]r+r+r,�_toAscii(szOutputChecker._toAsciicCs�|�|�}|�|�}||kr dS|t@sH||fdkr8dS||fdkrHdS|t@s�t�dt�t�d|�}t�dd|�}||kr�dS|t@r�d�|�	��}d�|�	��}||kr�dS|t
@r�t||�r�dSdS)	NT)zTrue
z1
)zFalse
z0
z(?m)^%s\s*?$r�z(?m)^[^\S\n]+$rZF)rJrrr[r\�escape�BLANKLINE_MARKERrr�rrrrz)rirurvrr+r+r,r!.s0


zOutputChecker.check_outputcCs<|ttBtB@sdS|t@r dS|�d�dko:|�d�dkS)NFTrFr3)r	r
rr�)rirurvrr+r+r,�_do_a_fancy_diffmszOutputChecker._do_a_fancy_diffc
Cs(|j}|t@st�dt|�}|�|||�r�|jdd�}|jdd�}|t@rptj	||dd�}t
|�dd�}d}nZ|t@r�tj||dd�}t
|�dd�}d}n,|t
@r�tjtjd�}	t
|	�||��}d	}nd
|td�|��S|r�|r�dt|�t|�fS|�rd
t|�S|�r dt|�SdSdS)Nz(?m)^[ ]*(?=
)T)r/r3)�nz#unified diff with -expected +actualz-context diff with expected followed by actual)Zcharjunkzndiff with -expected +actualzDifferences (%s):
r�zExpected:
%sGot:
%szExpected:
%sGot nothing
zExpected nothing
Got:
%szExpected nothing
Got nothing
)rurr[r\rLrMr2r	�difflibZunified_diff�listr
Zcontext_diffrZDifferZIS_CHARACTER_JUNKZcomparer_r�)
rirrvrrur�Z	got_linesZdiff�kindZenginer+r+r,r�s4zOutputChecker.output_differenceN)r5rnrorJr!rMrr+r+r+r,r s?c@seZdZdd�Zdd�ZdS)rcCs||_||_||_dS)N)rrrv)rirrrvr+r+r,r��szDocTestFailure.__init__cCs
t|j�S)N)r9r)rir+r+r,�__str__�szDocTestFailure.__str__N)r5rnror�rRr+r+r+r,r�sc@seZdZdd�Zdd�ZdS)rcCs||_||_||_dS)N)rrrd)rirrrdr+r+r,r��szUnexpectedException.__init__cCs
t|j�S)N)r9r)rir+r+r,rR�szUnexpectedException.__str__N)r5rnror�rRr+r+r+r,r�sc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rNTcCs$t�||||d�}|r |j��|S)NF)rrDr0r@)rirr'r�rC�rr+r+r,rD3s
zDebugRunner.runcCst|||��dS)N)r)rir�rrrdr+r+r,r9sz'DebugRunner.report_unexpected_exceptioncCst|||��dS)N)r)rir�rrrvr+r+r,r<szDebugRunner.report_failure)NNT)r5rnrorDrrr+r+r+r,r�s[
TFc	Cs�|dkrtj�d�}t�|�s,td|f��|dkr:|j}t|d�}	|rVt||d�}
nt	||d�}
x$|	j
||||d�D]}|
�|�qvW|r�|
��t
dkr�|
a
n
t
�|
�t|
j|
j�S)Nr�ztestmod: module required; %r)r�)r�r)r0r�)r=r>r.r6r7rAr5rrrrtrDrF�masterrHr%rr)r�r*r0r��reportrr��raise_on_errorr��finder�runnerrr+r+r,rHs$E


cCs�|r|std��t||||pd�\}}|dkr:tj�|�}|dkrHi}n|��}|dk	rb|�|�d|krrd|d<|	r�t||d�}
nt||d�}
|
�	||||d�}|
�
|�|r�|
��tdkr�|
an
t�
|
�t|
j|
j�S)Nz8Package may only be specified for module-relative paths.zutf-8r5r�)r�rr")r�rXr�r��basenamer�r�rrr�rDrFrTrHr%rr)rTrVr*rUr0r�rUrr�rVr�rN�textrXrr+r+r,r�s0R


�NoNamec	CsDt|dd�}t||d�}x&|j|||d�D]}|j||d�q*WdS)NF)r�r�)r�r)r0)r')rrrtrD)	rWr0r�r*r'rrWrXrr+r+r,r+scCs"|t@|krtd|��t}|a|S)NzOnly reporting flags allowed)r
r��_unittest_reportflags)r1�oldr+r+r,rHs

c@sjeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�ZeZ
dd�ZdS)�DocTestCaser"NcCs.tj�|�||_||_||_||_||_dS)N)�unittest�TestCaser��_dt_optionflags�_dt_checker�_dt_test�	_dt_setUp�_dt_tearDown)rirr�setUp�tearDownrr+r+r,r�nszDocTestCase.__init__cCs|j}|jdk	r|�|�dS)N)rcrd)rirr+r+r,rfxs
zDocTestCase.setUpcCs(|j}|jdk	r|�|�|j��dS)N)rcrer0r@)rirr+r+r,rg~s

zDocTestCase.tearDowncCs~|j}tj}t�}|j}|t@s(|tO}t||jdd�}z d|_	|j
||jdd�\}}Wd|t_X|rz|�|�
|�����dS)NF)rrr�zF----------------------------------------------------------------------)r�rC)rcr=r�r#rar
r\rrbr rDr7ZfailureException�format_failurerc)rirr]�newrrXrrr+r+r,�runTest�szDocTestCase.runTestcCsP|j}|jdkrd}n
d|j}d�|j�d�dd��}d|j|j|||fS)Nzunknown line numberz%sr�rpz:Failed doctest test for %s
  File "%s", line %s, in %s

%s)rcr�r�r*rrrT)ri�errrr�Zlnamer+r+r,rh�s

zDocTestCase.format_failurecCs6|��t|j|jdd�}|j|jdd�|��dS)NF)rrr�)rC)rfrrarbrDrcrg)rirXr+r+r,r!�s
BzDocTestCase.debugcCs|jjS)N)rcr*)rir+r+r,r��szDocTestCase.idcCsPt|�t|�k	rtS|j|jkoN|j|jkoN|j|jkoN|j|jkoN|j|jkS)N)r�r�rcrardrerb)rir�r+r+r,r��szDocTestCase.__eq__cCst|j|j|j|jf�S)N)r�rardrerb)rir+r+r,r��szDocTestCase.__hash__cCs,|jj�d�}d|dd�|dd��fS)Nr�z%s (%s)rp)rcr*rrr�)rir*r+r+r,r�	szDocTestCase.__repr__cCsd|jjS)Nz	Doctest: )rcr*)rir+r+r,�shortDescription		szDocTestCase.shortDescription)r"NNN)r5rnror�rfrgrjrhr!r�r�r�r�rRrlr+r+r+r,r^ls
	H
r^c@s0eZdZdd�Zdd�Zdd�Zdd�ZeZd	S)
�SkipDocTestCasecCs||_t�|d�dS)N)rBr^r�)rirBr+r+r,r�
	szSkipDocTestCase.__init__cCs|�d�dS)Nz-DocTestSuite will not work with -O2 and above)ZskipTest)rir+r+r,rf	szSkipDocTestCase.setUpcCsdS)Nr+)rir+r+r,�	test_skip	szSkipDocTestCase.test_skipcCsd|jjS)NzSkipping tests from %s)rBr5)rir+r+r,rl	sz SkipDocTestCase.shortDescriptionN)r5rnror�rfrnrlrRr+r+r+r,rm	s
rmc@seZdZdd�ZdS)�
_DocTestSuitecCsdS)Nr+)ri�indexr+r+r,�_removeTestAtIndex	sz _DocTestSuite._removeTestAtIndexN)r5rnrorqr+r+r+r,ro	sroc	Ks�|dkrt�}t|�}|j|||d�}|sNtjjdkrNt�}|�t|��|S|�	�t�}x\|D]T}t
|j�dkrvqb|js�|j
}|dd�dkr�|dd�}||_|�t|f|��qbW|S)N)r0r�r3r"rz.pycrp)rrDrtr=r1�optimizero�addTestrmr�r)r�rTr�r^)	rBr0r�Ztest_finderr�r��suiterrTr+r+r,r#	s(%
c@s(eZdZdd�Zdd�ZeZdd�ZdS)�DocFileCasecCsd�|jj�d��S)NrBr�)r�rcr*rr)rir+r+r,r�e	szDocFileCase.idcCs|jjS)N)rcrT)rir+r+r,r�h	szDocFileCase.__repr__cCsd|jj|jj|fS)Nz2Failed doctest test for %s
  File "%s", line 0

%s)rcr*rT)rirkr+r+r,rhl	szDocFileCase.format_failureN)r5rnror�r�rRrhr+r+r+r,ruc	sruc
Ksv|dkri}n|��}|r&|s&td��t||||p4d�\}}d|krL||d<tj�|�}|�||||d�}	t|	f|�S)Nz8Package may only be specified for module-relative paths.zutf-8r�r")r�r�rXr�r�rYr�ru)
r�rVrUr0r�rNr��docr*rr+r+r,�DocFileTestq	srwcOsHt�}|�dd�r$t|�d��|d<x|D]}|�t|f|��q*W|S)NrVTrU)ror.rDrsrw)�paths�kwrtr�r+r+r,r�	s8
cCs�g}x�t��|�D]x}t|t�rj|�|jdd��|j}|r�|�d�|dd�|�d�dd�D�7}q|dd�|�d�dd�D�7}qWx|r�|ddkr�|��q�Wx|r�|ddkr�|�d�q�Wd�	|�dS)	Nrpz# Expected:cSsg|]}d|�qS)z## r+)r�r�r+r+r,r�
sz(script_from_examples.<locals>.<listcomp>rFcSsg|]}t|��qSr+)r~)r�r�r+r+r,r�
sr{r")
rr�r8rr�r�rurr�popr�)r]r�Zpiecerur+r+r,r�	s:

"csJt|�}t��|�}�fdd�|D�}|s4t�d��|d}t|j�}|S)Ncsg|]}|j�kr|�qSr+)r*)r�r,)r*r+r,r�/
sztestsource.<locals>.<listcomp>znot found in testsr")rDrrtr�rr�)rBr*r�r�testsrcr+)r*r,r&
s

cCst|�}t|||�dS)N)r�debug_script)�src�pmr0r{r+r+r,r 6
scCs�ddl}|r|��}ni}|rvyt|||�Wq�tt��d�|jdd�}|��|�dt��d�Yq�Xn|jdd��	d|||�dS)Nr"r&T)r�r3zexec(%r))
r�r�r"r�r=rdr�r:ZinteractionrD)r}r~r0r��pr+r+r,r|;
s
r|cCs$t|�}t||�}t|||j�dS)N)rDrr|r�)rBr*r~r{r+r+r,r!O
s
c@s$eZdZdd�Zdd�Zdd�ZdS)�
_TestClasscCs
||_dS)N)r)rirr+r+r,r�k
sz_TestClass.__init__cCs|jd|_|S)Nr3)r)rir+r+r,�squareu
sz_TestClass.squarecCs|jS)N)r)rir+r+r,r.
sz_TestClass.getN)r5rnror�r�r.r+r+r+r,r�]
s

r�z�
                      Example of a string object, searched as-is.
                      >>> x = 1; y = 2
                      >>> x + y, x * y
                      (3, 2)
                      a�
                                    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
                                    z�
                Blank lines can be marked with <BLANKLINE>:
                    >>> print('foo\n\nbar\n')
                    foo
                    <BLANKLINE>
                    bar
                    <BLANKLINE>
            z�
                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]
            a�
                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]
            )r�r�zbool-int equivalencezblank linesZellipsiszwhitespace normalizationcCs*ddl}|jdd�}|jdddddd	�|jd
ddt��gd
d�|jddddd�|jdddd�|��}|j}|j}d}x|jD]}|t|O}q�W|j	r�|t
O}x~|D]v}|�d��rtj
�|�\}}tj
�d|�t|dd��}	tj
d=t|	||d�\}
}nt|d||d�\}
}|
r�dSq�WdS)Nr"zdoctest runner)�descriptionz-vz	--verbose�
store_trueFz'print very verbose output for all tests)�action�default�helpz-oz--optionr�zqspecify a doctest option flag to apply to the test run; may be specified more than once to apply multiple options)r��choicesr�r�z-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�r�r`r�z file containing the tests to run)�nargsr�z.py���)r�r)rVr�rr&)�argparse�ArgumentParser�add_argumentr'�keys�
parse_argsr`r�r�Z	fail_fastrrhr�r�rrr=�insertr:rr)r�r�r�Z	testfilesr�r�r�rT�dirnamer�rrBr+r+r,�_test�
s>


r�r�)r3)rY)	NNNNTr"NFF)Fr[Nr")NNNN)FN)FN)F)RZ
__docformat__�__all__r-rOr6r�r�r�r[r=rar_�ior#�collectionsr$r%r'rrrrrrrrr	r
rrrr
rLrqr2rDrJrXr_rfrgrzr~r�r�r�rOrrrrrr�	ExceptionrrrrTrrrr\rr`r^rmZ	TestSuiterorrurwrrrr r|r!r�r�r�r5�exitr+r+r+r,�<module>0s


1%.DKl<;n
fx
$!
@IR


,		-


Hacked By AnonymousFox1.0, Coded By AnonymousFox