Hacked By AnonymousFox

Current Path : /opt/alt/python36/lib64/python3.6/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/__pycache__/doctest.cpython-36.opt-2.pyc

3

��2aǗ�!@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Zd"d$l
mZd"d%lmZed&d'�ZiZd(d�Zed�Zed�Zed�Zed�Zed�Zed�ZeeBeBeBeBeBZed	�Zed
�Zed�Zed�Zed�ZeeBeBeBeBZ d)Z!d*Z"d+d,�Z#dpd.d/�Z$d0d1�Z%dqd3d4�Z&d5d6�Z'Gd7d8�d8e�Z(d9d:�Z)d;d<�Z*d=d>�Z+Gd?d@�d@ej,�Z-dAdB�Z.GdCd�d�Z/GdDd�d�Z0GdEd�d�Z1GdFd�d�Z2GdGd�d�Z3GdHd�d�Z4GdId�de5�Z6GdJd�de5�Z7GdKd�de3�Z8d#a9drdNd�Z:dLd#d#d#d#dLd"d#dMe1�d#fdOd�Z;dsdQd�Z<d"a=dRd�Z>GdSdT�dTej?�Z@GdUdV�dVe@�ZAGdWdX�dXejB�ZCdtdYd�ZDGdZd[�d[e@�ZEdLd#d#e1�d#fd\d]�ZFd^d�ZGd_d�ZHd`d�ZIdudad �ZJdvdbdc�ZKdwddd!�ZLGdedf�df�ZMeMdgdhdidjdkdl�ZNdmdn�ZOePdok�rle
jQeO��d#S)xzreStructuredText 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 attemptedcCstj|dtt�>�S)N�)�OPTIONFLAGS_BY_NAME�
setdefault�len)�name�r+�,/opt/alt/python36/lib64/python3.6/doctest.pyr�sz<BLANKLINE>z...cCs<d}x2tjD](}|j|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�cCsVtj|�r|St|t�r,t|t�t�dg�S|dkrJtjtj	|�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


rDc	Cs�|r\t|d�}t||�}t|dd�dk	r\t|jd�r\|jj|�}|j|�}|jtj	d�|fSt
||d��}|j�|fSQRXdS)N��
__loader__�get_data�
)�encoding)rD�_module_relative_pathr/�hasattrrFrG�decode�replace�os�linesep�open�read)�filename�package�module_relativerIZ
file_contents�fr+r+r,�_load_testfile�s


rV�cCstjd|d|�S)Nz
(?m)^(?!$)� )�re�sub)�s�indentr+r+r,�_indent�sr]cCs*t�}|\}}}tj||||d�|j�S)N)�file)r#�	traceback�print_exception�getvalue)�exc_infoZexcout�exc_typeZexc_valZexc_tbr+r+r,�_exception_traceback�s
rdc@seZdZdd�Zddd�ZdS)�	_SpoofOutcCs&tj|�}|r"|jd�r"|d7}|S)NrH)r#ra�endswith)�self�resultr+r+r,ra�s
z_SpoofOut.getvalueNcCs|j|�tj|�dS)N)�seekr#�truncate)rg�sizer+r+r,rjs
z_SpoofOut.truncate)N)r5�
__module__�__qualname__rarjr+r+r+r,re�s	recCs�t|kr||kS|jt�}dt|�}}|d}|rR|j|�rNt|�}|d=ndS|d}|r�|j|�r||t|�8}|d=ndS||kr�dSx2|D]*}|j|||�}|dkr�dS|t|�7}q�WdS)Nr"Fr&T���rn)�ELLIPSIS_MARKER�splitr)�
startswithrf�find)�want�gotZws�startpos�endpos�wr+r+r,�_ellipsis_matchs0



rxcCs|j�}|rd|SdSdS)Nz# �#)�rstrip)�liner+r+r,�
_comment_line9sr|cCshdt|�}}|jd�}|dkr$|}|jdd|�}|dkr>|}|jdd|�}|dkr\|d}|||�S)Nr"rH�:�.r&)r)rr�rfind)�msg�start�end�ir+r+r,�_strip_exception_detailsAs
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)rg�outr+r+r,r�asz_OutputRedirectingPdb.__init__NcCs*d|_|dkrtj�j}tjj||�dS)NT)r�r=r?�f_backr�r��	set_trace)rg�framer+r+r,r�is
z_OutputRedirectingPdb.set_tracecCs|jrtjj|�dS)N)r�r�r��set_continue)rgr+r+r,r�osz"_OutputRedirectingPdb.set_continuecGs.tj}|jt_ztjj|f|��S|t_XdS)N)r=r�r�r�r��trace_dispatch)rg�args�save_stdoutr+r+r,r�us
z$_OutputRedirectingPdb.trace_dispatch)N)r5rlrmr�r�r�r�r+r+r+r,r�[s
r�cCs�tj|�std|��|jd�r(td��tjj|jd��}t	|d�rXtjj|j
�d}n�|jdkr�tt
j�dkr�t
jddkr�tjjt
jd�d}q�tj}nFt	|d�r�x,|jD]"}tjj||�}tjj|�r�|Sq�Wtd	|j��tjj||�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__))r6r7rArq�
ValueErrorrN�path�joinrprKr�r5r)r=�argv�curdirr��exists)rBZ	test_pathZbasedirZ	directoryZfullpathr+r+r,rJ�s&





rJc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rNr"cCsz|jd�s|d7}|r*|jd�r*|d7}|dk	rF|jd�rF|d7}||_||_||_||_|dkrji}||_||_dS)NrH)rf�sourcers�linenor\�options�exc_msg)rgr�rsr�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�rsr�r\r�r�)rg�otherr+r+r,�__eq__�szExample.__eq__cCst|j|j|j|j|jf�S)N)�hashr�rsr�r\r�)rgr+r+r,�__hash__�szExample.__hash__)Nr"r"N)r5rlrmr�r�r�r+r+r+r,r�s#
c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)rcCs,||_||_|j�|_||_||_||_dS)N)�examples�	docstring�copyr0r*rRr�)rgr�r0r*rRr�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*rRr�)rgr�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*rRr�)rgr�r+r+r,r�#szDocTest.__eq__cCst|j|j|j|jf�S)N)r�r�r*rRr�)rgr+r+r,r�.szDocTest.__hash__cCs:t|t�stS|j|j|jt|�f|j|j|jt|�fkS)N)r8rr�r*rRr��id)rgr�r+r+r,�__lt__2s
zDocTest.__lt__N)r5rlrmr�r�r�r�r�r+r+r+r,r�s
c@s�eZdZejdejejB�ZejdejejBejB�Z	ejd�j
Zddd�Zdd�Z
dd	d
�Zdd�Zejd
ej�Zdd�Zejdej�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>cs|j�}|j|���dkr8dj�fdd�|jd�D��}g}d\}}x�|jj|�D]�}|j|||j���||jd||j��7}|j	|||�\}}}	}
|j
|�s�|jt||	|
|�t|j
d��|d��||jd|j�|j��7}|j�}qRW|j||d��|S)Nr"rHcsg|]}|�d��qS)Nr+)�.0�l)�
min_indentr+r,�
<listcomp>ysz'DocTestParser.parse.<locals>.<listcomp>r\)r�r\r�)r"r")�
expandtabs�_min_indentr�rp�_EXAMPLE_RE�finditer�appendr��count�_parse_example�_IS_BLANK_OR_COMMENTrr)�groupr�)rg�stringr*�outputZcharnor��mr�r�rsr�r+)r�r,�parsems&


zDocTestParser.parsecCst|j||�|||||�S)N)r�get_examples)rgr�r0r*rRr�r+r+r,�get_doctest�s	zDocTestParser.get_doctestcCsdd�|j||�D�S)NcSsg|]}t|t�r|�qSr+)r8r)r��xr+r+r,r��sz.DocTestParser.get_examples.<locals>.<listcomp>)r�)rgr�r*r+r+r,r��szDocTestParser.get_examplesc
s
t|jd���|jd�jd�}|j|�||�|j|dd�d�d||�dj�fdd�|D��}|jd	�}|jd�}t|�dkr�tjd
|d
�r�|d=|j|d�||t|��dj�fdd�|D��}|jj|�}|r�|jd�}nd}|j	|||�}	||	||fS)Nr\r�rHr&rXr~csg|]}|�dd��qS)rWNr+)r��sl)r\r+r,r��sz0DocTestParser._parse_example.<locals>.<listcomp>rsz *$csg|]}|�d��qS)Nr+)r�Zwl)r\r+r,r��sr�rnrn)
r)r�rp�_check_prompt_blank�
_check_prefixr�rY�match�
_EXCEPTION_RE�
_find_options)
rgr�r*r��source_linesr�rs�
want_linesr�r�r+)r\r,r��s$ 

zDocTestParser._parse_examplez#\s*doctest:\s*([^\n\'"]*)$c	Cs�i}x�|jj|�D]z}|jd�jdd�j�}x^|D]V}|ddksR|dd�tkrhtd|d||f��t|dd�}|ddk||<q2WqW|r�|j|�r�td|||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_REr�r�rMrpr'r�r�)	rgr�r*r�r�r��option_strings�option�flagr+r+r,r��s
zDocTestParser._find_optionsz
^([ ]*)(?=\S)cCs2dd�|jj|�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)rgr[�indentsr+r+r,r�szDocTestParser._min_indentc	Csbx\t|�D]P\}}t|�|dkr
||ddkr
td||d||||d�|f��q
WdS)NrWrErXz8line %r of the docstring for %s lacks blank after %s: %rr&)�	enumerater)r�)rg�linesr\r*r�r�r{r+r+r,r�
s
 z!DocTestParser._check_prompt_blankcCsDx>t|�D]2\}}|r
|j|�r
td||d||f��q
WdS)NzGline %r of the docstring for %s has inconsistent leading whitespace: %rr&)r�rqr�)rgr��prefixr*r�r�r{r+r+r,r�szDocTestParser._check_prefixN)r�)r�)r5rlrmrY�compile�	MULTILINE�VERBOSEr��DOTALLr�r�r�r�r�r�r�r�r�r�r�r�r�r+r+r+r,r=s 	
'
3c@sJeZdZde�ddfdd�Zddd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)rFTcCs||_||_||_||_dS)N)�_parser�_verbose�_recurse�_exclude_empty)rg�verbose�parser�recurse�
exclude_emptyr+r+r,r�1szDocTestFinder.__init__Nc	CsP|dkr.t|dd�}|dkr.tdt|�f��|dkr<d}n|dkrNtj|�}ytj|�}Wntk
rtd}YndX|s�tj|�}|d|dd�dks�d}|dkr�d}n*|dk	r�tj	||j
�}n
tj	|�}|s�d}|dk�r�|dkr�i}n
|j
j�}n|j�}|dk	�r|j|�d|k�r*d|d<g}|j
||||||i�|j�|S)	Nr5zJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rFr"r3z<]>r����)r/r�r�r6�	getmoduleZ
getsourcefilerAZgetfile�	linecache�getlines�__dict__r��update�_find�sort)	rg�objr*rBr0�
extraglobsr^r��testsr+r+r,rrGsJ$







zDocTestFinder.findcCs�|dkrdStj|�dk	r(|tj|�kStj|�r>|j|jkStj|�r|t|d�r\|jj}nt|d�rn|j}ndS|j	|kStj
|�r�|j	|jkSt|d�r�|j	|jkSt|t�r�dSt
d��dS)NT�__objclass__rlz"object must be a class or function)r6r��
isfunctionr��__globals__ZismethoddescriptorrKr�rlr5�isclassr8�propertyr�)rgrB�objectZobj_modr+r+r,�_from_module�s(








zDocTestFinder._from_modulec	Cs(|jrtd|�t|�|kr"dSd|t|�<|j|||||�}|dk	rR|j|�tj|�r�|jr�x^|jj	�D]P\}	}
d||	f}	tj
tj|
��s�tj|
�rn|j
||
�rn|j||
|	||||�qnWtj|�o�|j�rtx�t|di�j	�D]�\}	}
t|	t��stdt|	�f��tj
|
��p8tj|
��p8tj|
��p8t|
t��sNtdt|
�f��d||	f}	|j||
|	||||�q�Wtj|��r$|j�r$x�|jj	�D]�\}	}
t|
t��r�t||	�}
t|
t��r�t||	�j}
tj
|
��s�tj|
��s�t|
t��r�|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)r��printr��	_get_testr�r6r7r�r��itemsZ	isroutineZunwrapr�r�r�r/r8r9r�r��staticmethod�classmethod�__func__r�)rgr�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|j||�}|jrv|rvdS|dkr�d}n*t|d|j�}|dd�dkr�|dd�}|j	j
|||||�S)Nr�r�rWz.pycr&���rn)r8r9�__doc__rA�AttributeError�_find_linenor�r/r5r�r�)	rgr�r*rBr0r�r�r�rRr+r+r,r�s(



zDocTestFinder._get_testcCsd}tj|�rd}tj|�rd|dkr(dStjdt|dd��}x$t|�D]\}}|j|�rH|}PqHWtj|�rt|j	}tj
|�r�|j}tj|�r�|j
}tj|�r�|j}tj|�r�t|dd�d}|dk	�r|dkr�|dStjd�}x(t|t|��D]}|j||�r�|Sq�WdS)Nr"z^\s*class\s*%s\br5�-�co_firstlinenor&z(^|.*:)\s*\w*("|\'))r6r7r�rYr�r/r�r�Zismethodr�r��__code__Zistraceback�tb_frameZisframe�f_codeZiscode�ranger))rgr�r�r�Zpatr�r{r+r+r,r-s<









zDocTestFinder._find_lineno)NNNN)
r5rlrmrr�rrr�r�r�rr+r+r+r,r(s	
f?%c@s�eZdZddZddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zej
d�Zd dd�Zd!dd�Zd"dd�Zdd�ZdS)#rr4�FNr"cCsN|pt�|_|dkrdtjk}||_||_||_d|_d|_i|_	t
�|_dS)Nz-vr")r�_checkerr=r�r��optionflags�original_optionflags�tries�failures�_name2ftre�_fakeout)rg�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�rsr]r�)rgr�r�exampler+r+r,�report_start�s zDocTestRunner.report_startcCs|jr|d�dS)Nzok
)r�)rgr�rrrtr+r+r,�report_success�szDocTestRunner.report_successcCs&||j||�|jj|||j��dS)N)�_failure_headerr�output_differencer)rgr�rrrtr+r+r,�report_failure�szDocTestRunner.report_failurecCs$||j||�dtt|���dS)NzException raised:
)rr]rd)rgr�rrrbr+r+r,�report_unexpected_exception�sz)DocTestRunner.report_unexpected_exceptioncCs�|jg}|jrR|jdk	r4|jdk	r4|j|jd}nd}|jd|j||jf�n|jd|jd|jf�|jd�|j}|jt|��dj|�S)Nr&�?zFile "%s", line %s, in %szLine %s, in %szFailed example:rH)�DIVIDERrRr�r�r*r�r]r�)rgrrr�r�r�r+r+r,r�s
zDocTestRunner._failure_headercCs�d}}|j}td�\}}}	|jj}
�xFt|j�D�]6\}}|jt@oL|dk}
||_|jr�x:|jj�D],\}}|r�|j|O_qf|j|M_qfW|jt	@r�q2|d7}|
s�|j
|||�d|j|f}y,tt
|j|d|d�|j�|jj�d}Wn4tk
�r�Yntj�}|jj�YnX|jj�}|jjd�|}|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|j||||�nT||k�r0|
�s&|j ||||�|d7}n*||	k�rZ|
�sP|j!||||�|d7}n|r2|jt"@r2Pq2W||_|j#|||�t$||�S)Nr"rEr&z<doctest %s[%d]>Zsingler3rn)%rrr�check_outputr�r�rr�r�rrr*�execr�r�r0�debuggerr��KeyboardInterruptr=rbrrarjrsr_�format_exception_onlyrdr�rr�rrrr�_DocTestRunner__record_outcomer%)rgr�compileflagsr�rrr�SUCCESS�FAILUREZBOOMZcheck�
examplenumr�quietZ
optionflagrrRZ	exceptionrtZoutcomer�r+r+r,Z__run�s�












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





zDocTestRunner.runc
Cs�|dkr|j}g}g}g}d}}xd|jj�D]V}|\}\}	}
||
7}||	7}|
dkrb|j|�q.|	dkrz|j||
f�q.|j|�q.W|r�|r�tt|�d�|j�x|D]}td|�q�W|r�tt|�d�|j�x |D]\}}td||f�q�W|�rJt|j�tt|�d�|j�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�rr%)
rgr�ZnotestsZpassedZfailedZtotaltZtotalfr�r*rUr*�thingr�r+r+r,�	summarize�sP

zDocTestRunner.summarizecCsV|j}xJ|jj�D]<\}\}}||krB||\}}||}||}||f||<qWdS)N)rr�)rgr��dr*rUr*r+r,r+r+r,�mergeszDocTestRunner.merge)NNr")N)NNT)N)r5rlrmrr�rrrrrr<r$rYr�r.r9rBrDrFr+r+r+r,ras:
$
}



I
9c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
rcCst|jdd�d�S)N�ASCIIr3)r9r4)rgr[r+r+r,�_toAscii!szOutputChecker._toAsciicCs�|j|�}|j|�}||kr dS|t@sH||fdkr8dS||fdkrHdS|t@s�tjdtjt�d|�}tjdd|�}||kr�dS|t@r�d	j|j	��}d	j|j	��}||kr�dS|t
@r�t||�r�dSd
S)
NT�True
�1
�False
�0
z(?m)^%s\s*?$r�z
(?m)^\s*?$rXF)rIrJ)rKrL)rHrrrYrZ�escape�BLANKLINE_MARKERrr�rprrx)rgrsrtrr+r+r,r's0


zOutputChecker.check_outputcCs<|ttBtB@sdS|t@r dS|jd�dko:|jd�dkS)NFTrHr3)r	r
rr�)rgrsrtrr+r+r,�_do_a_fancy_difffszOutputChecker._do_a_fancy_diffc
Cs8|j}|t@stjdt|�}|j|||�r�|jdd�}|jdd�}|t@rptj	||dd�}t
|�dd�}d}nZ|t@r�tj||dd�}t
|�dd�}d}n,|t
@r�tjtjd�}	t
|	j||��}d	}nd
d�|D�}d|td
j|��S|o�|�rdt|�t|�fS|�rdt|�S|�r0dt|�SdSdS)Nz(?m)^[ ]*(?=
)T)r-r3)�nz#unified diff with -expected +actualz-context diff with expected followed by actual)Zcharjunkzndiff with -expected +actualcSsg|]}|j�d�qS)rH)rz)r�r{r+r+r,r��sz3OutputChecker.output_difference.<locals>.<listcomp>zDifferences (%s):
r�zExpected:
%sGot:
%szExpected:
%sGot nothing
zExpected nothing
Got:
%szExpected nothing
Got nothing
)rsrrYrZrNrOr0r	�difflibZunified_diff�listr
Zcontext_diffrZDifferZIS_CHARACTER_JUNKZcomparer]r�)
rgrrtrrsr�Z	got_linesZdiff�kindZenginer+r+r,r}s6
zOutputChecker.output_differenceN)r5rlrmrHrrOrr+r+r+r,rs?c@seZdZdd�Zdd�ZdS)rcCs||_||_||_dS)N)rrrt)rgrrrtr+r+r,r��szDocTestFailure.__init__cCs
t|j�S)N)r9r)rgr+r+r,�__str__�szDocTestFailure.__str__N)r5rlrmr�rTr+r+r+r,r�sc@seZdZdd�Zdd�ZdS)rcCs||_||_||_dS)N)rrrb)rgrrrbr+r+r,r��szUnexpectedException.__init__cCs
t|j�S)N)r9r)rgr+r+r,rT�szUnexpectedException.__str__N)r5rlrmr�rTr+r+r+r,r�sc@s&eZdZd	dd�Zdd�Zdd�ZdS)
rNTcCs$tj||||d�}|r |jj�|S)NF)rrBr0r>)rgrr%r�rA�rr+r+r,rB.s
zDebugRunner.runcCst|||��dS)N)r)rgr�rrrbr+r+r,r4sz'DebugRunner.report_unexpected_exceptioncCst|||��dS)N)r)rgr�rrrtr+r+r,r7szDebugRunner.report_failure)NNT)r5rlrmrBrrr+r+r+r,r�s[
TFc	Cs�|dkrtjjd�}tj|�s,td|f��|dkr:|j}t|d�}	|rVt||d�}
nt	||d�}
x$|	j
||||d�D]}|
j|�qvW|r�|
j�t
dkr�|
a
n
t
j|
�t|
j|
j�S)Nr�ztestmod: module required; %r)r�)r�r)r0r�)r=r>r.r6r7rAr5rrrrrrBrD�masterrFr%rr)r�r*r0r��reportrr��raise_on_errorr��finder�runnerrr+r+r,rCs$E


cCs�|r|rtd��t||||p d�\}}|dkr<tjj|�}|dkrJi}n|j�}|dk	rd|j|�d|krtd|d<|	r�t||d�}
nt||d�}
|
j	||||d�}|
j
|�|r�|
j�tdkr�|
an
tj
|
�t|
j|
j�S)Nz8Package may only be specified for module-relative paths.zutf-8r5r�)r�rr")r�rVrNr��basenamer�r�rrr�rBrDrVrFr%rr)rRrTr*rSr0r�rWrr�rXr�rI�textrZrr+r+r,r�s0R



�NoNamec	CsDt|dd�}t||d�}x&|j|||d�D]}|j||d�q*WdS)NF)r�r�)r�r)r0)r%)rrrrrB)	rUr0r�r*r%rrYrZrr+r+r,r&scCs"|t@|krtd|��t}|a|S)NzOnly reporting flags allowed)r
r��_unittest_reportflags)r1�oldr+r+r,rCs

c@sjeZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�ZeZ
dd�ZdS)�DocTestCaser"NcCs.tjj|�||_||_||_||_||_dS)N)�unittest�TestCaser��_dt_optionflags�_dt_checker�_dt_test�	_dt_setUp�_dt_tearDown)rgrr�setUp�tearDownrr+r+r,r�iszDocTestCase.__init__cCs|j}|jdk	r|j|�dS)N)rerf)rgrr+r+r,rhss
zDocTestCase.setUpcCs(|j}|jdk	r|j|�|jj�dS)N)rergr0r>)rgrr+r+r,riys

zDocTestCase.tearDowncCs�|j}tj}t�}|j}|t@s(|tO}t||jdd�}z$dd|_	|j
||jdd�\}}Wd|t_X|r~|j|j
|j����dS)NF)rrr�rr
)r�rA)rer=r�r#rcr
r^rrdrrBr5ZfailureException�format_failurera)rgrr_�newrrZrrr+r+r,�runTest�s
zDocTestCase.runTestcCsP|j}|jdkrd}n
d|j}dj|jjd�dd��}d|j|j|||fS)Nzunknown line numberz%sr~r&z:Failed doctest test for %s
  File "%s", line %s, in %s

%srn)rer�r�r*rprR)rg�errrr�Zlnamer+r+r,rj�s

zDocTestCase.format_failurecCs6|j�t|j|jdd�}|j|jdd�|j�dS)NF)rrr�)rA)rhrrcrdrBreri)rgrZr+r+r,r!�s
BzDocTestCase.debugcCs|jjS)N)rer*)rgr+r+r,r��szDocTestCase.idcCsPt|�t|�k	rtS|j|jkoN|j|jkoN|j|jkoN|j|jkoN|j|jkS)N)r�r�rercrfrgrd)rgr�r+r+r,r��szDocTestCase.__eq__cCst|j|j|j|jf�S)N)r�rcrfrgrd)rgr+r+r,r��szDocTestCase.__hash__cCs,|jjjd�}d|ddj|dd��fS)Nr~z%s (%s)r&rnrn)rer*rpr�)rgr*r+r+r,r��szDocTestCase.__repr__cCsd|jjS)Nz	Doctest: )rer*)rgr+r+r,�shortDescription	szDocTestCase.shortDescription)r"NNN)r5rlrmr�rhrirlrjr!r�r�r�r�rTrnr+r+r+r,r`gs
	H
r`c@s0eZdZdd�Zdd�Zdd�Zdd�ZeZd	S)
�SkipDocTestCasecCs||_tj|d�dS)N)rBr`r�)rgrBr+r+r,r�	szSkipDocTestCase.__init__cCs|jd�dS)Nz-DocTestSuite will not work with -O2 and above)ZskipTest)rgr+r+r,rh	szSkipDocTestCase.setUpcCsdS)Nr+)rgr+r+r,�	test_skip	szSkipDocTestCase.test_skipcCsd|jjS)NzSkipping tests from %s)rBr5)rgr+r+r,rn	sz SkipDocTestCase.shortDescriptionN)r5rlrmr�rhrprnrTr+r+r+r,ro	s
roc@seZdZdd�ZdS)�
_DocTestSuitecCsdS)Nr+)rg�indexr+r+r,�_removeTestAtIndex	sz _DocTestSuite._removeTestAtIndexN)r5rlrmrsr+r+r+r,rq	srqc	Ks�|dkrt�}t|�}|j|||d�}|rPtjjdkrPt�}|jt|��|S|j	�t�}x\|D]T}t
|j�dkrxqd|js�|j
}|dd�dkr�|dd�}||_|jt|f|��qdW|S)	N)r0r�r3r"rWz.pycr&rrn)rrDrrr=r1�optimizerq�addTestror�r)r�rRr�r`)	rBr0r�Ztest_finderr�r��suiterrRr+r+r,r	s(%
c@s(eZdZdd�Zdd�ZeZdd�ZdS)�DocFileCasecCsdj|jjjd��S)Nr@r~)r�rer*rp)rgr+r+r,r�`	szDocFileCase.idcCs|jjS)N)rerR)rgr+r+r,r�c	szDocFileCase.__repr__cCsd|jj|jj|fS)Nz2Failed doctest test for %s
  File "%s", line 0

%s)rer*rR)rgrmr+r+r,rjg	szDocFileCase.format_failureN)r5rlrmr�r�rTrjr+r+r+r,rw^	srwc
Ksx|dkri}n|j�}|r(|r(td��t||||p6d�\}}d|krN||d<tjj|�}|j||||d�}	t|	f|�S)Nz8Package may only be specified for module-relative paths.zutf-8r�r")r�r�rVrNr�r[r�rw)
r�rTrSr0r�rIr��docr*rr+r+r,�DocFileTestl	s
rycOsHt�}|jdd�r$t|jd��|d<x|D]}|jt|f|��q*W|S)NrTTrS)rqr.rDrury)�paths�kwrvr�r+r+r,r�	s8
cCs�g}x�t�j|�D]x}t|t�rj|j|jdd	��|j}|r�|jd�|dd�|jd�dd
�D�7}q|dd�|jd�dd�D�7}qWx|r�|ddkr�|j�q�Wx|r�|ddkr�|jd�q�Wdj	|�dS)
Nr&z# Expected:cSsg|]}d|�qS)z## r+)r�r�r+r+r,r�
sz(script_from_examples.<locals>.<listcomp>rHcSsg|]}t|��qSr+)r|)r�r�r+r+r,r�
sryr"rnrnrnrn)
rr�r8rr�r�rsrp�popr�)r[r�Zpiecersr+r+r,r�	s:

"csJt|�}t�j|�}�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")rDrrrr�rr�)rBr*r�r�testsrcr+)r*r,r!
s

cCst|�}t|||�dS)N)r�debug_script)�src�pmr0r}r+r+r,r 1
sc
Cs�ddl}|r|j�}ni}|rvyt|||�Wq�ttj�d�|jdd�}|j�|jdtj�d�Yq�Xn|jdd�j	d|||�dS)Nr"r&T)r�r3zexec(%r))
r�r�r r�r=rbr�r8ZinteractionrB)rr�r0r��pr+r+r,r~6
s
r~cCs$t|�}t||�}t|||j�dS)N)rDrr~r�)rBr*r�r}r+r+r,r!J
s
c@s$eZdZdd�Zdd�Zdd�ZdS)�
_TestClasscCs
||_dS)N)r)rgrr+r+r,r�f
sz_TestClass.__init__cCs|jd|_|S)Nr3)r)rgr+r+r,�squarep
sz_TestClass.squarecCs|jS)N)r)rgr+r+r,r.z
sz_TestClass.getN)r5rlrmr�r�r.r+r+r+r,r�X
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 normalizationcCs tjdd�}|jdddddd�|jd	d
dtj�gdd
�|jddddd�|jdddd�|j�}|j}|j}d}x|jD]}|t|O}q|W|j	r�|t
O}x||D]t}|jd�r�tj
j|�\}}tj
jd|�t|dd��}tj
d=t|||d�\}	}
nt|d||d�\}	}
|	r�dSq�WdS)Nzdoctest 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�r"z.pyrE)r�r)rTr�rr&���)�argparse�ArgumentParser�add_argumentr'�keys�
parse_argsr^r�r�Z	fail_fastrrfrNr�rpr=�insertr:rr)r�r�Z	testfilesr�r�r�rR�dirnamer�rr@r+r+r,�_test�
s<



r�r�)r3)rW)	NNNNTr"NFF)Fr]Nr")NNNN)FN)FN)F)RZ
__docformat__�__all__r-r�rQr6r�rNr�rYr=r_ra�ior#�collectionsr$r%r'rrrrrrrrr	r
rrrr
rNror2rDrVr]rdrerxr|r�r�r�rJrrrrrr�	ExceptionrrrrVrrrr^rrbr`roZ	TestSuiterqrrwryrrrr 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