AlkantarClanX12

Your IP : 18.191.195.105


Current Path : /proc/self/root/lib64/python3.8/__pycache__/
Upload File :
Current File : //proc/self/root/lib64/python3.8/__pycache__/doctest.cpython-38.opt-2.pyc

U

e5d_��!@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,�/usr/lib64/python3.8/doctest.pyr�sz<BLANKLINE>z...cCs8d}tjD](}|�|d�}|tt|�kr
||jO}q
|S)Nr")�
__future__Zall_feature_names�get�getattrZ
compiler_flag)�globs�flagsZfnameZfeaturer,r,r-�_extract_future_flags�s
r3�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)�moduleZdepthr,r,r-�_normalize_module�s


rDcCsdD]}|�|d�}q|S)N)z
�
�
)�replace)�data�newliner,r,r-�_newline_convert�srJc
Cs�|rVt|d�}t||�}t|dd�dk	rVt|jd�rV|j�|�}|�|�}t|�|fSt||d��}|�	�|fW5QR�SQRXdS)N��
__loader__�get_data)�encoding)
rD�_module_relative_pathr0�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)rj�sizer,r,r-rn	s
z_SpoofOut.truncate)N)r6�
__module__�__qualname__rcrnr,r,r,r-rg�s	rgcCs�t|kr||kS|�t�}dt|�}}|d}|rR|�|�rNt|�}|d=ndS|d}|r�|�|�r||t|�8}|d=ndS||kr�dS|D],}|�|||�}|dkr�dS|t|�7}q�dS)Nr"F���T)�ELLIPSIS_MARKER�splitr)�
startswithri�find)�want�gotZws�startpos�endpos�wr,r,r-�_ellipsis_matchs0


r|cCs|��}|rd|SdSdS)Nz# �#)�rstrip)�liner,r,r-�
_comment_line?sr�cCshdt|�}}|�d�}|dkr$|}|�dd|�}|dkr>|}|�dd|�}|dkr\|d}|||�S)Nr"rF�:�.r&)r)rv�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)rj�outr,r,r-r�gsz_OutputRedirectingPdb.__init__NcCs*d|_|dkrt��j}tj�||�dS)NT)r�r>r@�f_backr�r��	set_trace)rj�framer,r,r-r�os
z_OutputRedirectingPdb.set_tracecCs|jrtj�|�dSrl)r�r�r��set_continue�rjr,r,r-r�usz"_OutputRedirectingPdb.set_continuecGs2tj}|jt_ztjj|f|��W�S|t_XdSrl)r>r�r�r�r��trace_dispatch)rj�args�save_stdoutr,r,r-r�{s
z$_OutputRedirectingPdb.trace_dispatch)N)r6rprqr�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�|jD]&}tj�||�}tj�|�r�|Sq�td	|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__))r7r8rBru�
ValueError�os�path�joinrtrPr�r6r)r>�argv�curdirr��exists)rCZ	test_pathZbasedirZ	directory�fullpathr,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}||_||_dSrh)ri�sourcerw�linenor^�options�exc_msg)rjr�rwr�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|jkSrl)�type�NotImplementedr�rwr�r^r�r��rj�otherr,r,r-�__eq__�s
�
�
�
�
�zExample.__eq__cCst|j|j|j|j|jf�Srl)�hashr�rwr�r^r�r�r,r,r-�__hash__�s�zExample.__hash__)Nr"r"N)r6rprqr�r�r�r,r,r,r-r�s
#�
c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCs,||_||_|��|_||_||_||_dSrl)�examples�	docstring�copyr1r+rTr�)rjr�r1r+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__r6r+rTr�)rjr�r,r,r-�__repr__s��zDocTest.__repr__cCs\t|�t|�k	rtS|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkSrl)r�r�r�r�r1r+rTr�r�r,r,r-r�)s
�
�
�
�
�zDocTest.__eq__cCst|j|j|j|jf�Srl)r�r�r+rTr�r�r,r,r-r�4szDocTest.__hash__cCs:t|t�stS|j|j|jt|�f|j|j|jt|�fkSrl)r9rr�r+rTr��idr�r,r,r-�__lt__8s

�zDocTest.__lt__N)r6rprqr�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\}}|j�|�D]�}|�|||����||�d||���7}|�	|||�\}}}	}
|�
|�s�|�t||	|
|�t|�
d��|d��||�d|��|���7}|��}qP|�||d��|S)Nr"rFcsg|]}|�d��qSrlr,��.0�l�Z
min_indentr,r-�
<listcomp>sz'DocTestParser.parse.<locals>.<listcomp>�r"r"r^)r�r^r�)�
expandtabs�_min_indentr�rt�_EXAMPLE_RE�finditer�appendr��count�_parse_example�_IS_BLANK_OR_COMMENTrr)�groupr�)rj�stringr+�outputZcharnor��mr�r�rwr�r,r�r-�parsess*
�

�
zDocTestParser.parsecCst|�||�|||||�Srl)r�get_examples)rjr�r1r+rTr�r,r,r-�get_doctest�s	�zDocTestParser.get_doctestcCsdd�|�||�D�S)NcSsg|]}t|t�r|�qSr,)r9r)r��xr,r,r-r��s
�z.DocTestParser.get_examples.<locals>.<listcomp>)r�)rjr�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�Zsl�r^r,r-r��sz0DocTestParser._parse_example.<locals>.<listcomp>rwz *$rrcsg|]}|�d��qSrlr,)r�Zwlr�r,r-r��sr�)
r)r�rt�_check_prompt_blank�
_check_prefixr�r[�match�
_EXCEPTION_RE�
_find_options)
rjr�r+r��source_linesr�rw�
want_linesr�r�r,r�r-r��s& 


�zDocTestParser._parse_examplez#\s*doctest:\s*([^\n\'"]*)$c	Cs�i}|j�|�D]v}|�d��dd���}|D]V}|ddksN|dd�tkrdtd|d||f��t|dd�}|ddk||<q.q|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�rGrtr'r�r�)	rjr�r+r�r�r�Zoption_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)rjr]�indentsr,r,r-r�szDocTestParser._min_indentc	Cs^t|�D]P\}}t|�|dkr||ddkrtd||d||||d�|f��qdS)NrYrKrZz8line %r of the docstring for %s lacks blank after %s: %rr&)�	enumerater)r�)rj�linesr^r+r�r�rr,r,r-r�s ��z!DocTestParser._check_prompt_blankcCs>t|�D]0\}}|r|�|�std||d||f��qdS)NzGline %r of the docstring for %s has inconsistent leading whitespace: %rr&)r�rur�)rjr��prefixr+r�r�rr,r,r-r�s
�zDocTestParser._check_prefixN)r�)r�)r6rprqr[�compile�	MULTILINE�VERBOSEr��DOTALLr�r�r�r�r�r�r�r�r�r�r�r�r�r,r,r,r-rCs&	
��
'
3�c@sJeZdZde�ddfdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)rFTcCs||_||_||_||_dSrl)�_parser�_verbose�_recurse�_exclude_empty)rj�verbose�parser�recurse�
exclude_emptyr,r,r-r�7szDocTestFinder.__init__Nc		CsN|dkr.t|dd�}|dkr.tdt|�f��|dkr<d}n|dkrNt�|�}zt�|�}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)Nr6zJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rFr"���z<]>r�)r0r�r�r7�	getmoduleZ
getsourcefilerBZgetfile�	linecache�getlines�__dict__r��update�_find�sort)	rj�objr+rCr1�
extraglobsr`r��testsr,r,r-rvMsL$�






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__rpz"object must be a class or function)r7r��
isfunctionr��__globals__ZismethoddescriptorrPr�rpr6�isclassr9�propertyr�)rjrC�objectZobj_modr,r,r-�_from_module�s(








zDocTestFinder._from_modulec
Cs|jrtd|�t|�|kr"dSd|t|�<|�|||||�}|dk	rR|�|�t�|�r�|jr�|j�	�D]P\}	}
d||	f}	t�
t�|
��s�t�|
�rl|�
||
�rl|�||
|	||||�qlt�|��rn|j�rnt|di��	�D]�\}	}
t|	t��stdt|	�f��t�
|
��sJt�|
��sJt�|
��sJt|
t��sJtdt|
�f��d||	f}	|�||
|	||||�q�t�|��r|j�r|j�	�D]�\}	}
t|
t��r�t||	�}
t|
t��r�t||	�j}
t�
|
��s�t�|
��s�t|
t��r�|�
||
��r�d||	f}	|�||
|	||||��q�dS)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�r7r8r�r��itemsZ	isroutineZunwrapr�rr�r0r9r:r�r��staticmethod�classmethod�__func__r�)rjr�r�r+rCr�r1�seen�testZvalname�valr,r,r-r��sn
�
�������
�
��zDocTestFinder._findc		Cs�t|t�r|}nJz,|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�����.pycrr)r9r:�__doc__rB�AttributeError�_find_linenor�r0r6r�r�)	rjr�r+rCr1r�r�r�rTr,r,r-rs,




�zDocTestFinder._get_testcCsd}t�|�rd}t�|�rb|dkr(dSt�dt|dd��}t|�D]\}}|�|�rF|}qbqFt�|�rr|j	}t�
|�r�|j}t�|�r�|j
}t�|�r�|j}t�|�r�t|dd�d}|dk	�r
|dkr�|dSt�d�}t|t|��D]}|�||�r�|Sq�dS)Nr"z^\s*class\s*%s\br6�-�co_firstlinenor&z(^|.*:)\s*\w*("|\'))r7r8r�r[r�r0r�r�Zismethodrr��__code__Zistraceback�tb_frameZisframe�f_codeZiscode�ranger))rjr�r�r�Zpatr�rr,r,r-r4s>


�








zDocTestFinder._find_lineno)NNNN)
r6rprqrr�rvrr�rrr,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)N�-vr")r�_checkerr>r�r��optionflags�original_optionflags�tries�failures�_name2ftrg�_fakeout)rj�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�rwr_r�)rjr�r
�exampler,r,r-�report_start�s���zDocTestRunner.report_startcCs|jr|d�dS)Nzok
)r��rjr�r
r rxr,r,r-�report_success�szDocTestRunner.report_successcCs&||�||�|j�|||j��dSrl)�_failure_headerr�output_differencerr"r,r,r-�report_failure�s�zDocTestRunner.report_failurecCs$||�||�dtt|���dS)NzException raised:
)r$r_rf�rjr�r
r rdr,r,r-�report_unexpected_exception�s
�
�z)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�)rjr
r r�r�r�r,r,r-r$�s�
zDocTestRunner._failure_headerc	Cs�d}}|j}td�\}}}	|jj}
t|j�D�]6\}}|jt@oH|dk}
||_|jr�|j��D],\}}|r||j|O_q`|j|M_q`|jt	@r�q.|d7}|
s�|�
|||�d|j|f}z,tt
|j|d|d�|j�|j��d}Wn4tk
�r�Ynt��}|j��YnX|j��}|j�d�|}|dk�r`|
|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�|
�sR|�||||�nT||k�r(|
�s|� ||||�|d7}n*||	k�rR|
�sH|�!||||�|d7}n|r.|jt"@r.�qhq.||_|�#|||�t$||�S)Nr"rKr&z<doctest %s[%d]>Zsingler4rr)%rrr�check_outputr�r�rr�rrr!r+�execr�r�r1�debuggerr��KeyboardInterruptr>rdrrcrnrwra�format_exception_onlyrfr�rr�r#r&r(r�_DocTestRunner__record_outcomer%)rjr
�compileflagsr�rrr�SUCCESS�FAILUREZBOOMZcheck�
examplenumr �quietZ
optionflagrrTZ	exceptionrxZoutcomer�r,r,r-Z__run�s�
�
��



�




�
zDocTestRunner.__runcCsL|j�|jd�\}}||||f|j|j<|j|7_|j|7_dS)Nr�)rr/r+rr)rjr
rW�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+r4T��keepends)
�%_DocTestRunner__LINECACHE_FILENAME_REr�r�r
r+r��intr��
splitlines�save_linecache_getlines)rjrT�module_globalsr�r r,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|�|||�W�S�t_|t
_t�|�|jt_|t_|�r�|j��ddl}d|_XdS)N�utf-8cs t|��d���}��|�dS)N�backslashreplace)r:�encode�write)r]�rNr�r,r-r��szDocTestRunner.run.<locals>.outr")r
r3r1r>r�rN�lowerrCr�gettracer�r�r�r-�resetr�r�r>�*_DocTestRunner__patched_linecache_getlines�displayhook�__displayhook__�settrace�clear�builtins�_�_DocTestRunner__run)	rjr
r1r��clear_globsZ
save_traceZsave_set_traceZsave_displayhookrMr,rDr-�run�s<





zDocTestRunner.runc
Cs�|dkr|j}g}g}g}d}}|j��D]V}|\}\}	}
||
7}||	7}|
dkr`|�|�q,|	dkrx|�||
f�q,|�|�q,|r�|r�tt|�d�|��|D]}td|�q�|r�tt|�d�|��|D]\}}td||f�q�|�r:t|j�tt|�d�|��|D] \}\}	}
td|	|
|f��q|�rft|dt|j�d	�t||d
|d�|�rztd|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�rrr�rr)r�r*r%)
rjr�ZnotestsZpassedZfailedZtotaltZtotalfr�r+rWr6�thingr�r,r,r-�	summarize�sP
zDocTestRunner.summarizecCsR|j}|j��D]<\}\}}||kr@||\}}||}||}||f||<qdSrl)rr)rjr��dr+rWr6r7r8r,r,r-�mergeszDocTestRunner.merge)NNr")N)NNT)N)r6rprqr*r�r!r#r&r(r$rOr0r[r�r;rHrQrSrUr,r,r,r-rhs:
$
}



I
9c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCst|�dd�d�S)N�ASCIIrA)r:rB)rjr]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)rWrrr[r\�escape�BLANKLINE_MARKERrr�rtrr|�rjrwrxrr,r,r-r+.s4

�
zOutputChecker.check_outputcCs<|ttBtB@sdS|t@r dS|�d�dko:|�d�dkS)NFTrFr4)r	r
rr�rZr,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)^[ ]*(?=
)Tr9r4)�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
)rwrr[r\rYr[r=r	�difflibZunified_diff�listr
Zcontext_diffrZDifferZIS_CHARACTER_JUNKZcomparer_r�)
rjr rxrrwr�Z	got_linesZdiffZkindZenginer,r,r-r%�s4zOutputChecker.output_differenceN)r6rprqrWr+r[r%r,r,r,r-r s?c@seZdZdd�Zdd�ZdS)rcCs||_||_||_dSrl)r
r rx)rjr
r rxr,r,r-r��szDocTestFailure.__init__cCs
t|j�Srl�r:r
r�r,r,r-�__str__�szDocTestFailure.__str__N�r6rprqr�r`r,r,r,r-r�sc@seZdZdd�Zdd�ZdS)rcCs||_||_||_dSrl)r
r rd)rjr
r rdr,r,r-r��szUnexpectedException.__init__cCs
t|j�Srlr_r�r,r,r-r`�szUnexpectedException.__str__Nrar,r,r,r-r�sc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rNTcCs$t�||||d�}|r |j��|S)NF)rrQr1rL)rjr
r1r�rP�rr,r,r-rQ3s
zDebugRunner.runcCst|||��dSrl)rr'r,r,r-r(9sz'DebugRunner.report_unexpected_exceptioncCst|||��dSrl)rr"r,r,r-r&<szDebugRunner.report_failure)NNT)r6rprqrQr(r&r,r,r,r-r�s[
TFc	Cs�|dkrtj�d�}t�|�s,td|f��|dkr:|j}t|d�}	|rVt||d�}
nt	||d�}
|	j
||||d�D]}|
�|�qt|r�|
��t
dkr�|
a
n
t
�|
�t|
j|
j�S)Nr�ztestmod: module required; %r)r��r�r�r1r�)r>r?r/r7r8rBr6rrrrvrQrS�masterrUr%rr)r�r+r1r��reportrr��raise_on_errorr��finder�runnerr
r,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)N�8Package may only be specified for module-relative paths.r@r6r�rcr")r�rXr�r��basenamer�r�rrr�rQrSrerUr%rr)rTrVr+rUr1r�rfrr�rgr�rN�textrir
r,r,r-r�s2R�


�NoNamec	Cs@t|dd�}t||d�}|j|||d�D]}|j||d�q(dS)NF)r�r�rc)r1)r1)rrrvrQ)	rWr1r�r+r1rrhrir
r,r,r-r+scCs"|t@|krtd|��t}|a|S)NzOnly reporting flags allowed)r
r��_unittest_reportflags)r2�oldr,r,r-rHs

c@sleZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Ze
jZdd�ZdS)�DocTestCaser"NcCs.tj�|�||_||_||_||_||_dSrl)�unittest�TestCaser��_dt_optionflags�_dt_checker�_dt_test�	_dt_setUp�_dt_tearDown)rjr
r�setUp�tearDownrr,r,r-r�nszDocTestCase.__init__cCs|j}|jdk	r|�|�dSrl)rurv�rjr
r,r,r-rxxs
zDocTestCase.setUpcCs(|j}|jdk	r|�|�|j��dSrl)rurwr1rLrzr,r,r-ry~s

zDocTestCase.tearDowncCs~|j}tj}t�}|j}|t@s(|tO}t||jdd�}z d|_	|j
||jdd�\}}W5|t_X|rz|�|�
|�����dS)NF�rrr�zF----------------------------------------------------------------------)r�rP)rur>r�r#rsr
rnrrtr*rQrCZfailureException�format_failurerc)rjr
ro�newrrirrr,r,r-�runTest�s(��zDocTestCase.runTestcCsP|j}|jdkrd}n
d|j}d�|j�d�dd��}d|j|j|||fS)Nzunknown line numberz%sr�rrz:Failed doctest test for %s
  File "%s", line %s, in %s

%s)rur�r�r+rtrT)rj�errr
r�Zlnamer,r,r-r|�s

�zDocTestCase.format_failurecCs6|��t|j|jdd�}|j|jdd�|��dS)NFr{)rP)rxrrsrtrQrury)rjrir,r,r-r!�sB�zDocTestCase.debugcCs|jjSrl�rur+r�r,r,r-r��szDocTestCase.idcCsPt|�t|�k	rtS|j|jkoN|j|jkoN|j|jkoN|j|jkoN|j|jkSrl)r�r�rursrvrwrtr�r,r,r-r��s
�
�
�
�zDocTestCase.__eq__cCst|j|j|j|jf�Srl)r�rsrvrwrtr�r,r,r-r��s�zDocTestCase.__hash__cCs,|jj�d�}d|dd�|dd��fS)Nr�z%s (%s)rr)rur+rtr�)rjr+r,r,r-r�	szDocTestCase.__repr__cCsd|jjS)Nz	Doctest: r�r�r,r,r-�shortDescription		szDocTestCase.shortDescription)r"NNN)r6rprqr�rxryr~r|r!r�r�r�r�rr`r�r,r,r,r-rpls�

H
rpc@s0eZdZdd�Zdd�Zdd�Zdd�ZeZd	S)
�SkipDocTestCasecCs||_t�|d�dSrl)rCrpr�)rjrCr,r,r-r�
	szSkipDocTestCase.__init__cCs|�d�dS)Nz-DocTestSuite will not work with -O2 and above)ZskipTestr�r,r,r-rx	szSkipDocTestCase.setUpcCsdSrlr,r�r,r,r-�	test_skip	szSkipDocTestCase.test_skipcCsd|jjS)NzSkipping tests from %s)rCr6r�r,r,r-r�	sz SkipDocTestCase.shortDescriptionN)r6rprqr�rxr�r�r`r,r,r,r-r�	s
r�c@seZdZdd�ZdS)�
_DocTestSuitecCsdSrlr,)rj�indexr,r,r-�_removeTestAtIndex	sz _DocTestSuite._removeTestAtIndexN)r6rprqr�r,r,r,r-r�	sr�c	Ks�|dkrt�}t|�}|j|||d�}|sNtjjdkrNt�}|�t|��|S|�	�t�}|D]T}t
|j�dkrtq`|js�|j
}|dd�dkr�|dd�}||_|�t|f|��q`|S)Nrdr4r"rr
rr)rrDrvr>r2�optimizer��addTestr�r�r)r�rTr�rp)	rCr1r�Ztest_finderr�r��suiter
rTr,r,r-r#	s(%c@s$eZdZdd�Zdd�Zdd�ZdS)�DocFileCasecCsd�|jj�d��S)NrNr�)r�rur+rtr�r,r,r-r�e	szDocFileCase.idcCs|jjSrl)rurTr�r,r,r-r�h	szDocFileCase.__repr__cCsd|jj|jj|fS)Nz2Failed doctest test for %s
  File "%s", line 0

%s)rur+rT)rjrr,r,r-r|k	s�zDocFileCase.format_failureN)r6rprqr�r�r|r,r,r,r-r�c	sr�c
Ksv|dkri}n|��}|r&|s&td��t||||p4d�\}}d|krL||d<tj�|�}|�||||d�}	t|	f|�S)Nrjr@r�r")r�r�rXr�r�rkr�r�)
r�rVrUr1r�rNr��docr+r
r,r,r-�DocFileTestp	s�r�cOsDt�}|�dd�r$t|�d��|d<|D]}|�t|f|��q(|S)NrVTrU)r�r/rDr�r�)�paths�kwr�r�r,r,r-r�	s8cCs�g}t��|�D]x}t|t�rh|�|jdd��|j}|r�|�d�|dd�|�d�dd�D�7}q|dd�|�d�dd�D�7}q|r�|ddkr�|��q�|r�|ddkr�|�d�q�d�	|�dS)	Nrrz# Expected:cSsg|]}d|�qS)z## r,r�r,r,r-r�
sz(script_from_examples.<locals>.<listcomp>rFcSsg|]}t|��qSr,)r�r�r,r,r-r�
s�r}r")
rr�r9rr�r�rwrt�popr�)r]r�Zpiecerwr,r,r-r�	s :

"�

csJt|�}t��|�}�fdd�|D�}|s4t�d��|d}t|j�}|S)Ncsg|]}|j�kr|�qSr,r*)r�r6r*r,r-r�.
s
ztestsource.<locals>.<listcomp>znot found in testsr")rDrrvr�rr�)rCr+r�r
�testsrcr,r*r-r%
s

cCst|�}t|||�dSrl)r�debug_script)�src�pmr1r�r,r,r-r 5
scCs�ddl}|r|��}ni}|rvzt|||�Wq�tt��d�|jdd�}|��|�dt��d�Yq�Xn|jdd��	d|||�dS)Nr"r&T)r�r4zexec(%r))
r�r�r,rr>rdr�rGZinteractionrQ)r�r�r1r��pr,r,r-r�:
s
r�cCs$t|�}t||�}t|||j�dSrl)rDrr�r�)rCr+r�r�r,r,r-r!N
s
c@s$eZdZdd�Zdd�Zdd�ZdS)�
_TestClasscCs
||_dSrl�r)rjrr,r,r-r�j
sz_TestClass.__init__cCs|jd|_|S)Nr4r�r�r,r,r-�squaret
sz_TestClass.squarecCs|jSrlr�r�r,r,r-r/~
sz_TestClass.getN)r6rprqr�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}|jD]}|t|O}q�|j	r�|t
O}|D]v}|�d�r�tj
�|�\}}tj
�d|�t|dd��}	tj
d=t|	||d�\}
}nt|d||d�\}
}|
r�dSq�dS)Nr"zdoctest runner)Zdescriptionrz	--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���rc)rVr�rr&)�argparse�ArgumentParser�add_argumentr'�keys�
parse_argsr`r�r�Z	fail_fastrrir�r�rtr>�insertr;rr)r�r�r�Z	testfilesr�r�r�rT�dirnamer�rrNr,r,r-�_test�
sL�
�
��

�
r�r�)r4)rY)	NNNNTr"NFF)FrmNr")NNNN)FN)FN)F)RZ
__docformat__�__all__r.r]r7r�r�r�r[r>rarq�ior#�collectionsr$r%r'rrrrrrrrr	r
rrrr
rYrsr3rDrJrXr_rfrgr|r�r�r�r�rOrrrrrr�	Exceptionrrrrerrrrnrrrrpr�Z	TestSuiter�rr�r�rrrr r�r!r�rr�r6�exitr,r,r,r-�<module>0sD�-
���������

1%.DKl<;n�
h�
{�
$!
@
�
IR


,	�3-