Your IP : 3.147.140.133


Current Path : /lib64/python2.7/
Upload File :
Current File : //lib64/python2.7/doctest.pyc

�
�mec!@s�dZdZdddddddd	d
ddd
ddddddddddddddddddd d!d"g!Zd#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
Z
d#d$lZd#d%lmZd#d&lmZed'd(�ZiZd)�Zed�Zed�Zed�Zed�Zed�Zed�ZeeBeBeBeBeBZed
�Zed�Zed�Zed
�ZeeBeBeBZ d*Z!d+Z"d,�Z#d-d.�Z$d/�Z%e&ej'd0e(�p)d1Z)d2d3�Z*d4�Z+d5efd6��YZ,d7�Z-d8�Z.d9ej/fd:��YZ0d;�Z1dfd<��YZ2dfd=��YZ3dfd>��YZ4dfd?��YZ5dfd@��YZ6dfdA��YZ7de8fdB��YZ9de8fdC��YZ:de6fdD��YZ;e(a<e(e(e(e(e=dEe(e>e>dF�	Z?e=e(e(e(e(e=dEe(e>e4�e(dG�Z@e>dHe(dEdI�ZAdfdJ��YZBdEaCdK�ZDdLe
jEfdM��YZFdNeFfdO��YZGe(e(e(e(dP�ZHdQeFfdR��YZIe=e(e(e4�e(dS�ZJdT�ZKdU�ZLdV�ZMe>e(dW�ZNe>e(dX�ZOe>dY�ZPdZfd[��YZQieQdZ6d\d]6d^d_6d`da6dbdc6ddde6ZRdf�ZSeTdgkr�ejUeS��nd$S(hs�Module doctest -- a framework for running examples in docstrings.

In simplest use, end each module M to be tested with:

def _test():
    import doctest
    doctest.testmod()

if __name__ == "__main__":
    _test()

Then running the module as a script will cause the examples in the
docstrings to get executed and verified:

python M.py

This won't display anything unless an example fails, in which case the
failing example(s) and the cause(s) of the failure(s) are printed to stdout
(why not stderr? because stderr is a lame hack <0.2 wink>), and the final
line of output is "Test failed.".

Run it with the -v switch instead:

python M.py -v

and a detailed report of all examples tried is printed to stdout, along
with assorted summaries at the end.

You can force verbose mode by passing "verbose=True" to testmod, or prohibit
it by passing "verbose=False".  In either of those cases, sys.argv is not
examined by testmod.

There are a variety of other ways to run doctests, including integration
with the unittest framework, and support for running non-Python text
files containing doctests.  There are also many ways to override parts
of doctest's default behaviors.  See the Library Reference Manual for
details.
sreStructuredText entregister_optionflagtDONT_ACCEPT_TRUE_FOR_1tDONT_ACCEPT_BLANKLINEtNORMALIZE_WHITESPACEtELLIPSIStSKIPtIGNORE_EXCEPTION_DETAILtCOMPARISON_FLAGStREPORT_UDIFFtREPORT_CDIFFtREPORT_NDIFFtREPORT_ONLY_FIRST_FAILUREtREPORTING_FLAGStExampletDocTestt
DocTestParsert
DocTestFindert
DocTestRunnert
OutputCheckertDocTestFailuretUnexpectedExceptiontDebugRunnerttestmodttestfiletrun_docstring_examplestTestertDocTestSuitetDocFileSuitetset_unittest_reportflagstscript_from_examplest
testsourcet	debug_srctdebugi����N(tStringIO(t
namedtupletTestResultssfailed attemptedcCstj|dtt�>�S(Ni(tOPTIONFLAGS_BY_NAMEt
setdefaulttlen(tname((s/usr/lib64/python2.7/doctest.pyR�ss<BLANKLINE>s...cCsUd}xHtjD]=}|j|d�}|tt|�kr||jO}qqW|S(s�
    Return the compiler-flags associated with the future features that
    have been imported into the given namespace (globs).
    iN(t
__future__tall_feature_namestgettNonetgetattrt
compiler_flag(tglobstflagstfnametfeature((s/usr/lib64/python2.7/doctest.pyt_extract_future_flags�sicCs{tj|�r|St|ttf�rDt|t�t�dg�S|dkrkt	j
t	j|�jdSt
d��dS(s�
    Return the module specified by `module`.  In particular:
      - If `module` is a module, then return module.
      - If `module` is a string, then import and return the
        module with that name.
      - If `module` is None, then return the calling module.
        The calling module is assumed to be the module of
        the stack frame at the given depth in the call stack.
    t*t__name__s"Expected a module, string, or NoneN(tinspecttismodulet
isinstancetstrtunicodet
__import__tglobalstlocalsR+tsystmodulest	_getframet	f_globalst	TypeError(tmoduletdepth((s/usr/lib64/python2.7/doctest.pyt_normalize_module�s
cCs�|rvt|d�}t||�}t|d�rvt|jd�rs|jj|�}|jtjd�|fSqvnt|��}|j	�|fSWdQXdS(Nit
__loader__tget_datas
(
RDt_module_relative_paththasattrRERFtreplacetostlineseptopentread(tfilenametpackagetmodule_relativet
file_contentstf((s/usr/lib64/python2.7/doctest.pyt_load_testfile�stencodingsutf-8icCs;t|t�r$|jtd�}ntjd|d|�S(s�
    Add the given number of space characters to the beginning of
    every non-blank line in `s`, and return the result.
    If the string `s` is Unicode, it is encoded using the stdout
    encoding and the `backslashreplace` error handler.
    tbackslashreplaces
(?m)^(?!$)t (R7R9tencodet	_encodingtretsub(tstindent((s/usr/lib64/python2.7/doctest.pyt_indent�scCs;t�}|\}}}tj|||d|�|j�S(sz
    Return a string containing a traceback message for the given
    exc_info tuple (as returned by sys.exc_info()).
    tfile(R!t	tracebacktprint_exceptiontgetvalue(texc_infotexcouttexc_typetexc_valtexc_tb((s/usr/lib64/python2.7/doctest.pyt_exception_traceback�s	t	_SpoofOutcBseZd�Zdd�ZRS(cCsNtj|�}|r2|jd�r2|d7}nt|d�rJ|`n|S(Ns
t	softspace(R!RatendswithRHRi(tselftresult((s/usr/lib64/python2.7/doctest.pyRa�s
	cCsAtj||�t|d�r(|`n|js=d|_ndS(NRit(R!ttruncateRHRitbuf(Rktsize((s/usr/lib64/python2.7/doctest.pyRns
		N(R4t
__module__RaR+Rn(((s/usr/lib64/python2.7/doctest.pyRh�s	
cCs&t|kr||kS|jt�}t|�dks=t�dt|�}}|d}|r�|j|�r�t|�}|d=q�tSn|d}|r�|j|�r�|t|�8}|d=q�tSn||kr�tSxC|D];}|j|||�}|dkrtS|t|�7}q�WtS(s_
    Essentially the only subtle case:
    >>> _ellipsis_match('aa...aa', 'aaa')
    False
    iii����(	tELLIPSIS_MARKERtsplitR&tAssertionErrort
startswithtFalseRjtfindtTrue(twanttgottwststartpostendpostw((s/usr/lib64/python2.7/doctest.pyt_ellipsis_matchs2





cCs"|j�}|rd|SdSdS(s)Return a commented form of the given lines# t#N(trstrip(tline((s/usr/lib64/python2.7/doctest.pyt
_comment_lineAst_OutputRedirectingPdbcBs5eZdZd�Zdd�Zd�Zd�ZRS(s�
    A specialized version of the python debugger that redirects stdout
    to a given stream when interacting with the user.  Stdout is *not*
    redirected when traced code is executed.
    cCs5||_t|_tjj|d|�d|_dS(Ntstdouti(t_OutputRedirectingPdb__outRvt$_OutputRedirectingPdb__debugger_usedtpdbtPdbt__init__tuse_rawinput(Rktout((s/usr/lib64/python2.7/doctest.pyR�Os		cCs>t|_|dkr'tj�j}ntjj||�dS(N(	RxR�R+R=R?tf_backR�R�t	set_trace(Rktframe((s/usr/lib64/python2.7/doctest.pyR�Vs	cCs |jrtjj|�ndS(N(R�R�R�tset_continue(Rk((s/usr/lib64/python2.7/doctest.pyR�\s	cGs=tj}|jt_ztjj||�SWd|t_XdS(N(R=R�R�R�R�ttrace_dispatch(Rktargstsave_stdout((s/usr/lib64/python2.7/doctest.pyR�bs
	N(R4Rqt__doc__R�R+R�R�R�(((s/usr/lib64/python2.7/doctest.pyR�Is
		cCs�tj|�std|�n|jd�r:td�nt|d�retjj|j	�d}nw|j
dkr�ttj
�dkr�tj
ddkr�tjjtj
d�d}q�tj}ntd|d	��tjj||jd��S(
NsExpected a module: %rt/s1Module-relative files may not have absolute pathst__file__it__main__Rms+Can't resolve paths relative to the module s (it has no __file__)(R5R6RARut
ValueErrorRHRJtpathRsR�R4R&R=targvtcurdirtjoin(RBR�tbasedir((s/usr/lib64/python2.7/doctest.pyRGms( cBs>eZdZddddd�Zd�Zd�Zd�ZRS(sn
    A single doctest example, consisting of source code and expected
    output.  `Example` defines the following attributes:

      - source: A single Python statement, always ending with a newline.
        The constructor adds a newline if needed.

      - want: The expected output from running the source code (either
        from stdout, or a traceback in case of exception).  `want` ends
        with a newline unless it's empty, in which case it's an empty
        string.  The constructor adds a newline if needed.

      - exc_msg: The exception message generated by the example, if
        the example is expected to generate an exception; or `None` if
        it is not expected to generate an exception.  This exception
        message is compared against the return value of
        `traceback.format_exception_only()`.  `exc_msg` ends with a
        newline unless it's `None`.  The constructor adds a newline
        if needed.

      - lineno: The line number within the DocTest string containing
        this Example where the Example begins.  This line number is
        zero-based, with respect to the beginning of the DocTest.

      - indent: The example's indentation in the DocTest string.
        I.e., the number of space characters that preceed the
        example's first prompt.

      - options: A dictionary mapping from option flags to True or
        False, which is used to override default options for this
        example.  Any option flags not contained in this dictionary
        are left at their default value (as specified by the
        DocTestRunner's optionflags).  By default, no options are set.
    icCs�|jd�s|d7}n|r?|jd�r?|d7}n|dk	rh|jd�rh|d7}n||_||_||_||_|dkr�i}n||_||_dS(Ns
(RjR+tsourceRytlinenoR\toptionstexc_msg(RkR�RyR�R�R\R�((s/usr/lib64/python2.7/doctest.pyR��s


						cCs�t|�t|�k	rtS|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jkS(N(ttypetNotImplementedR�RyR�R\R�R�(Rktother((s/usr/lib64/python2.7/doctest.pyt__eq__�scCs||kS(N((RkR�((s/usr/lib64/python2.7/doctest.pyt__ne__�scCs(t|j|j|j|j|jf�S(N(thashR�RyR�R\R�(Rk((s/usr/lib64/python2.7/doctest.pyt__hash__�sN(R4RqR�R+R�R�R�R�(((s/usr/lib64/python2.7/doctest.pyR
�s"			cBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(se
    A collection of doctest examples that should be run in a single
    namespace.  Each `DocTest` defines the following attributes:

      - examples: the list of examples.

      - globs: The namespace (aka globals) that the examples should
        be run in.

      - name: A name identifying the DocTest (typically, the name of
        the object whose docstring this DocTest was extracted from).

      - filename: The name of the file that this DocTest was extracted
        from, or `None` if the filename is unknown.

      - lineno: The line number within filename where this DocTest
        begins, or `None` if the line number is unavailable.  This
        line number is zero-based, with respect to the beginning of
        the file.

      - docstring: The string that the examples were extracted from,
        or `None` if the string is unavailable.
    cCs\t|t�std��||_||_|j�|_||_||_||_	dS(s�
        Create a new DocTest containing the given examples.  The
        DocTest's globals are initialized with a copy of `globs`.
        s8DocTest no longer accepts str; use DocTestParser insteadN(
R7t
basestringRttexamplest	docstringtcopyR.R'RNR�(RkR�R.R'RNR�R�((s/usr/lib64/python2.7/doctest.pyR��s					cCslt|j�dkrd}n1t|j�dkr<d}ndt|j�}d|j|j|j|fS(Nisno examplesis	1 examples%d exampless<DocTest %s from %s:%s (%s)>(R&R�R'RNR�(RkR�((s/usr/lib64/python2.7/doctest.pyt__repr__�s		cCs�t|�t|�k	rtS|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jkS(N(R�R�R�R�R.R'RNR�(RkR�((s/usr/lib64/python2.7/doctest.pyR�	scCs||kS(N((RkR�((s/usr/lib64/python2.7/doctest.pyR�scCs"t|j|j|j|jf�S(N(R�R�R'RNR�(Rk((s/usr/lib64/python2.7/doctest.pyR�scCsVt|t�sdSt|j|j|jt|�f|j|j|jt|�f�S(Ni����(R7RtcmpR'RNR�tid(RkR�((s/usr/lib64/python2.7/doctest.pyt__cmp__s!(	R4RqR�R�R�R�R�R�R�(((s/usr/lib64/python2.7/doctest.pyR�s		
			cBs�eZdZejdejejB�ZejdejejBejB�Z	ejd�j
Zdd�Zd�Z
dd�Zd�Zejd	ej�Zd
�Zejdej�Zd�Zd
�Zd�ZRS(sD
    A class used to parse strings containing doctest examples.
    s�
        # 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
                  )*)
        s�
        # 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.
        s^[ ]*(#.*)?$s<string>c

Csx|j�}|j|�}|dkrYdjg|jd�D]}||^q=�}ng}d\}}x�|jj|�D]�}|j|||j�!�||jd||j��7}|j	|||�\}	}
}}|j
|	�s.|jt|	||d|d|t|j
d��d|
��n||jd|j�|j��7}|j�}q~W|j||�|S(s=
        Divide the given string into examples and intervening text,
        and return them as a list of alternating Examples and strings.
        Line numbers for the Examples are 0-based.  The optional
        argument `name` is a name identifying this string, and is only
        used for error messages.
        is
R�R\R�(ii(t
expandtabst_min_indentR�Rst_EXAMPLE_REtfinditertappendtstarttcountt_parse_examplet_IS_BLANK_OR_COMMENTR
R&tgrouptend(
RktstringR't
min_indenttltoutputtcharnoR�tmR�R�RyR�((s/usr/lib64/python2.7/doctest.pytparseUs&2!
%cCs%t|j||�|||||�S(s"
        Extract all doctest examples from the given string, and
        collect them into a `DocTest` object.

        `globs`, `name`, `filename`, and `lineno` are attributes for
        the new `DocTest` object.  See the documentation for `DocTest`
        for more information.
        (Rtget_examples(RkR�R.R'RNR�((s/usr/lib64/python2.7/doctest.pytget_doctest|s	cCs2g|j||�D]}t|t�r|^qS(s�
        Extract all doctest examples from the given string, and return
        them as a list of `Example` objects.  Line numbers are
        0-based, because it's most common in doctests that nothing
        interesting appears on the same line as opening triple-quote,
        and so the first interesting line is called "line 1" then.

        The optional argument `name` is a name identifying this
        string, and is only used for error messages.
        (R�R7R
(RkR�R'tx((s/usr/lib64/python2.7/doctest.pyR��sc
Cs~t|jd��}|jd�jd�}|j||||�|j|dd|d||�djg|D]}||d^qr�}|jd�}|jd�}	t|	�dkr�tjd	|	d
�r�|	d
=n|j|	d|||t|��djg|	D]}
|
|^q�}|jj|�}|rS|jd�}nd}|j
|||�}||||fS(
s�
        Given a regular expression match from `_EXAMPLE_RE` (`m`),
        return a pair `(source, want)`, where `source` is the matched
        example's source code (with prompts and indentation stripped);
        and `want` is the example's expected output (with indentation
        stripped).

        `name` is the string's name, and `lineno` is the line number
        where the example starts; both are used for error messages.
        R\R�s
iRVt.iRys *$i����tmsgN(R&R�Rst_check_prompt_blankt
_check_prefixR�RYtmatcht
_EXCEPTION_RER+t
_find_options(
RkR�R'R�R\tsource_linestslR�Ryt
want_linestwlR�R�((s/usr/lib64/python2.7/doctest.pyR��s$"*(
&s#\s*doctest:\s*([^\n\'"]*)$c	Cs�i}x�|jj|�D]�}|jd�jdd�j�}xp|D]h}|ddksm|dtkr�td|d||f��nt|d}|ddk||<qGWqW|r�|j|�r�td|||f��n|S(	s
        Return a dictionary containing option overrides extracted from
        option directives in the given source string.

        `name` is the string's name, and `lineno` is the line number
        where the example starts; both are used for error messages.
        it,RVis+-s7line %r of the doctest for %s has an invalid option: %rt+sSline %r of the doctest for %s has an option directive on a line with no example: %r(t_OPTION_DIRECTIVE_RER�R�RIRsR$R�R�(	RkR�R'R�R�R�toption_stringstoptiontflag((s/usr/lib64/python2.7/doctest.pyR��s!
s
^([ ]*)(?=\S)cCsOg|jj|�D]}t|�^q}t|�dkrGt|�SdSdS(s;Return the minimum indentation of any non-blank line in `s`iN(t
_INDENT_REtfindallR&tmin(RkR[R\tindents((s/usr/lib64/python2.7/doctest.pyR��s+
c
Cs}xvt|�D]h\}}t|�|dkr
||ddkr
td||d||||d!|f��q
q
WdS(s

        Given the lines of a source string (including prompts and
        leading indentation), check to make sure that every prompt is
        followed by a space character.  If any line is not followed by
        a space character, then raise ValueError.
        iiRVs8line %r of the docstring for %s lacks blank after %s: %riN(t	enumerateR&R�(RktlinesR\R'R�tiR�((s/usr/lib64/python2.7/doctest.pyR��s
*cCs[xTt|�D]F\}}|r
|j|�r
td||d||f��q
q
WdS(s�
        Check that every line in the given list starts with the given
        prefix; if any line does not, then raise a ValueError.
        sGline %r of the docstring for %s has inconsistent leading whitespace: %riN(R�RuR�(RkR�tprefixR'R�R�R�((s/usr/lib64/python2.7/doctest.pyR�s(R4RqR�RYtcompilet	MULTILINEtVERBOSER�tDOTALLR�R�R�R�R�R�R�R�R�R�R�R�R�(((s/usr/lib64/python2.7/doctest.pyR%s"'		3				cBs_eZdZee�eed�Zddddd�Zd�Z	d�Z
d�Zd�ZRS(s<
    A class used to extract the DocTests that are relevant to a given
    object, from its docstring and the docstrings of its contained
    objects.  Doctests can currently be extracted from the following
    object types: modules, functions, classes, methods, staticmethods,
    classmethods, and properties.
    cCs(||_||_||_||_dS(st
        Create a new doctest finder.

        The optional argument `parser` specifies a class or
        function that should be used to create new DocTest objects (or
        objects that implement the same interface as DocTest).  The
        signature for this factory function should match the signature
        of the DocTest constructor.

        If the optional argument `recurse` is false, then `find` will
        only examine the given object, and not any contained objects.

        If the optional argument `exclude_empty` is false, then `find`
        will include tests for objects with empty docstrings.
        N(t_parsert_verboset_recurset_exclude_empty(Rktverbosetparsertrecurset
exclude_empty((s/usr/lib64/python2.7/doctest.pyR�s			c		Cs�|dkrIt|dd�}|dkrItdt|�f��qIn|tkr^d}n|dkr|tj|�}nydtj|�p�tj|�}|dk	r�t	j
||j�}nt	j
|�}|s�d}nWntk
r�d}nX|dkr-|dkri}q9|jj
�}n|j
�}|dk	rU|j|�nd|krnd|d<ng}|j||||||i�|j�|S(sj
        Return a list of the DocTests that are defined by the given
        object's docstring, or by any of its contained objects'
        docstrings.

        The optional parameter `module` is the module that contains
        the given object.  If the module is not specified or is None, then
        the test finder will attempt to automatically determine the
        correct module.  The object's module is used:

            - As a default namespace, if `globs` is not specified.
            - To prevent the DocTestFinder from extracting DocTests
              from objects that are imported from other modules.
            - To find the name of the file containing the object.
            - To help find the line number of the object within its
              file.

        Contained objects whose module does not match `module` are ignored.

        If `module` is False, no attempt to find the module will be made.
        This is obscure, of use mostly in tests:  if `module` is False, or
        is None but cannot be found automatically, then all objects are
        considered to belong to the (non-existent) module, so all contained
        objects will (recursively) be searched for doctests.

        The globals for each DocTest is formed by combining `globs`
        and `extraglobs` (bindings in `extraglobs` override bindings
        in `globs`).  A new copy of the globals dictionary is created
        for each DocTest.  If `globs` is not specified, then it
        defaults to the module's `__dict__`, if specified, or {}
        otherwise.  If `extraglobs` is not specified, then it defaults
        to {}.

        R4sJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rR�N(R+R,R�R�RvR5t	getmodulet
getsourcefiletgetfilet	linecachetgetlinest__dict__RAR�tupdatet_findtsort(	RktobjR'RBR.t
extraglobsR^R�ttests((s/usr/lib64/python2.7/doctest.pyRw/s>$	


	

cCs�|dkrtStj|�dk	r8|tj|�kStj|�rW|j|jkStj|�rv|j|j	kSt
|d�r�|j|j	kSt|t�r�tSt
d��dS(sY
        Return true if the given object is defined in the given
        module.
        Rqs"object must be a class or functionN(R+RxR5R�t
isfunctionR�tfunc_globalstisclassR4RqRHR7tpropertyR�(RkRBtobject((s/usr/lib64/python2.7/doctest.pyt_from_module�scCs	|jrd|GHnt|�|kr+dSd|t|�<|j|||||�}|dk	rr|j|�ntj|�r|jrx�|jj	�D]n\}	}
d||	f}	tj
|
�s�tj|
�r�|j||
�r�|j
||
|	||||�q�q�Wntj|�r|jrx�t|di�j	�D]�\}	}
t|	t�swtdt|	�f��ntj
|
�p�tj|
�p�tj|
�p�tj|
�p�t|
t�s�tdt|
�f��nd||	f}	|j
||
|	||||�q@Wntj|�r|jrx�|jj	�D]�\}	}
t|
t�rit||	�}
nt|
t�r�t||	�j}
ntj
|
�s�tj|
�s�t|
t�r<|j||
�r<d||	f}	|j
||
|	||||�q<q<WndS(	sm
        Find tests for the given object and any contained objects, and
        add them to `tests`.
        sFinding tests in %sNis%s.%st__test__s5DocTestFinder.find: __test__ keys must be strings: %rs`DocTestFinder.find: __test__ values must be strings, functions, methods, classes, or modules: %rs%s.__test__.%s(R�R�t	_get_testR+R�R5R6R�R�titemsR�R�R�R�R,R7R�R�R�tismethodtstaticmethodtclassmethodtim_funcR�(RkR�R�R'RBR�R.tseenttesttvalnametval((s/usr/lib64/python2.7/doctest.pyR��sP	%c	Cst|t�r|}ncyC|jdkr3d}n'|j}t|t�sZt|�}nWnttfk
rzd}nX|j||�}|jr�|r�dS|dkr�d}n2t	|d|j
�}|ddkr�|d }n|jj|||||�S(	ss
        Return a DocTest for the given object, if it defines a docstring;
        otherwise, return None.
        RmR�i����s.pycs.pyoi����N(s.pycs.pyo(
R7R�R�R+R8RAtAttributeErrort_find_linenoR�R,R4R�R�(	RkR�R'RBR.R�R�R�RN((s/usr/lib64/python2.7/doctest.pyR��s(			
	
cCs�d}tj|�rd}ntj|�r�|dkr=dStjdt|dd��}x6t|�D]%\}}|j|�ri|}PqiqiWntj	|�r�|j
}ntj|�r�|j}ntj
|�r�|j}ntj|�r|j}ntj|�r)t|dd�d}n|dk	r�|dkrI|dStjd�}x7t|t|��D]}|j||�rn|SqnWndS(	s�
        Return a line number of the given object's docstring.  Note:
        this method assumes that the object has a docstring.
        is^\s*class\s*%s\bR4t-tco_firstlinenois(^|.*:)\s*\w*("|')N(R+R5R6R�RYR�R,R�R�RRR�t	func_codetistracebackttb_frametisframetf_codetiscodetrangeR&(RkR�R�R�tpatR�R�((s/usr/lib64/python2.7/doctest.pyR	s<		N(
R4RqR�RvRRxR�R+RwR�R�R�R	(((s/usr/lib64/python2.7/doctest.pyRs	]		?	%cBs�eZdZddZdddd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Ze
jd�Zdd
�Zdded�Zdd�Zd�ZRS(s2	
    A class used to run DocTest test cases, and accumulate statistics.
    The `run` method is used to process a single DocTest case.  It
    returns a tuple `(f, t)`, where `t` is the number of test cases
    tried, and `f` is the number of test cases that failed.

        >>> tests = DocTestFinder().find(_TestClass)
        >>> runner = DocTestRunner(verbose=False)
        >>> tests.sort(key = lambda test: test.name)
        >>> for test in tests:
        ...     print test.name, '->', runner.run(test)
        _TestClass -> TestResults(failed=0, attempted=2)
        _TestClass.__init__ -> TestResults(failed=0, attempted=2)
        _TestClass.get -> TestResults(failed=0, attempted=2)
        _TestClass.square -> TestResults(failed=0, attempted=1)

    The `summarize` method prints a summary of all the test cases that
    have been run by the runner, and returns an aggregated `(f, t)`
    tuple:

        >>> runner.summarize(verbose=1)
        4 items passed all tests:
           2 tests in _TestClass
           2 tests in _TestClass.__init__
           2 tests in _TestClass.get
           1 tests in _TestClass.square
        7 tests in 4 items.
        7 passed and 0 failed.
        Test passed.
        TestResults(failed=0, attempted=7)

    The aggregated number of tried examples and failed examples is
    also available via the `tries` and `failures` attributes:

        >>> runner.tries
        7
        >>> runner.failures
        0

    The comparison between expected outputs and actual outputs is done
    by an `OutputChecker`.  This comparison may be customized with a
    number of option flags; see the documentation for `testmod` for
    more information.  If the option flags are insufficient, then the
    comparison may also be customized by passing a subclass of
    `OutputChecker` to the constructor.

    The test runner's display output can be controlled in two ways.
    First, an output function (`out) can be passed to
    `TestRunner.run`; this function will be called with strings that
    should be displayed.  It defaults to `sys.stdout.write`.  If
    capturing the output is not sufficient, then the display output
    can be also customized by subclassing DocTestRunner, and
    overriding the methods `report_start`, `report_success`,
    `report_unexpected_exception`, and `report_failure`.
    R3iFicCsv|pt�|_|dkr0dtjk}n||_||_||_d|_d|_	i|_
t�|_dS(sc
        Create a new test runner.

        Optional keyword arg `checker` is the `OutputChecker` that
        should be used to compare the expected outputs and actual
        outputs of doctest examples.

        Optional keyword arg 'verbose' prints lots of stuff if true,
        only failures if false; by default, it's true iff '-v' is in
        sys.argv.

        Optional argument `optionflags` can be used to control how the
        test runner compares expected output to actual output, and how
        it displays failures.  See the documentation for `testmod` for
        more information.
        s-viN(
Rt_checkerR+R=R�R�toptionflagstoriginal_optionflagsttriestfailurest_name2ftRht_fakeout(RktcheckerR�R((s/usr/lib64/python2.7/doctest.pyR�ts						cCs_|jr[|jr=|dt|j�dt|j��q[|dt|j�d�ndS(s�
        Report that the test runner is about to process the given
        example.  (Only displays a message if verbose=True)
        sTrying:
sExpecting:
sExpecting nothing
N(R�RyR]R�(RkR�Rtexample((s/usr/lib64/python2.7/doctest.pytreport_start�s		(cCs|jr|d�ndS(st
        Report that the given example ran successfully.  (Only
        displays a message if verbose=True)
        sok
N(R�(RkR�RRRz((s/usr/lib64/python2.7/doctest.pytreport_success�s	cCs3||j||�|jj|||j��dS(s7
        Report that the given example failed.
        N(t_failure_headerRtoutput_differenceR(RkR�RRRz((s/usr/lib64/python2.7/doctest.pytreport_failure�scCs.||j||�dtt|���dS(sO
        Report that the given example raised an unexpected exception.
        sException raised:
N(RR]Rg(RkR�RRRb((s/usr/lib64/python2.7/doctest.pytreport_unexpected_exception�scCs�|jg}|jrs|jdk	rJ|jdk	rJ|j|jd}nd}|jd|j||jf�n!|jd|jd|jf�|jd�|j}|jt|��dj|�S(Nit?sFile "%s", line %s, in %ssLine %s, in %ssFailed example:s
(	tDIVIDERRNR�R+R�R'R�R]R�(RkRRR�R�R�((s/usr/lib64/python2.7/doctest.pyR�s		!
	c	Bs�d}}|j}ed�\}}}	|jj}
x?e|j�D].\}}|je@of|dk}
||_|jr�xH|jj�D]4\}}|r�|j|O_q�|j|M_q�Wn|je	@r�qDn|d7}|
s�|j
|||�nd|j|f}y7e|j
|d|d�|jU|jj�d
}Wn3ek
r_�n ej�}|jj�nX|jj�}|jjd�|}|d
kr�|
|j||j�r�|}q�n�ej�}ej|d �d}|
s|e|�7}n|jd
kr(|	}n�|
|j||j�rI|}ns|je@r�ejd|j�}ejd|�}|r�|r�|
|j d�|j d�|j�r�|}q�n||kr�|
sr|j!||||�qrqD||kr"|
s|j"||||�n|d7}qD||	krZ|
sM|j#||||�n|d7}qDe$sDt%d	|f��qDW||_|j&|||�e'||�S(s�
        Run the examples in `test`.  Write the outcome of each example
        with one of the `DocTestRunner.report_*` methods, using the
        writer function `out`.  `compileflags` is the set of compiler
        flags that should be used to execute examples.  Return a tuple
        `(f, t)`, where `t` is the number of examples tried, and `f`
        is the number of examples that failed.  The examples are run
        in the namespace `test.globs`.
        iiis<doctest %s[%d]>tsingleii����s(?:[^:]*\.)?([^:]*:)sunknown outcomeN((RRRtcheck_outputR�R�RR�R�RRR'R�R�R.tdebuggerR�R+tKeyboardInterruptR=RbRRaRnRyR_tformat_exception_onlyRgR�RRYR�R�RR!R"RvRtt_DocTestRunner__record_outcomeR#(RkRtcompileflagsR�RRRtSUCCESStFAILUREtBOOMtcheckt
examplenumRtquiett
optionflagRRNt	exceptionRztoutcomeRbR�tm1tm2((s/usr/lib64/python2.7/doctest.pyt__run�s�
	
		




		
'


	cCs^|jj|jd�\}}||||f|j|j<|j|7_|j|7_dS(s{
        Record the fact that the given DocTest (`test`) generated `f`
        failures out of `t` tried examples.
        iN(ii(RR*R'RR(RkRRRtttf2tt2((s/usr/lib64/python2.7/doctest.pyt__record_outcomeKss.<doctest (?P<name>.+)\[(?P<examplenum>\d+)\]>$cCs�|jj|�}|r�|jd�|jjkr�|jjt|jd��}|j}t|t	�r|j
dd�}n|jt�S|j
||�SdS(NR'R0tasciiRU(t%_DocTestRunner__LINECACHE_FILENAME_RER�R�RR'R�tintR�R7R9RWt
splitlinesRxtsave_linecache_getlines(RkRNtmodule_globalsR�RR�((s/usr/lib64/python2.7/doctest.pyt__patched_linecache_getlinesXs!	
cCs||_|dkr't|j�}ntj}|dkrH|j}n|jt_tj	}t
|�|_|jj�|jj	t_	t
j|_|jt
_tj}tjt_z|j|||�SWd|t_|t_	|jt
_|t_|r|jj�nXdS(sJ
        Run the examples in `test`, and display the results using the
        writer function `out`.

        The examples are run in the namespace `test.globs`.  If
        `clear_globs` is true (the default), then this namespace will
        be cleared after the test runs, to help with garbage
        collection.  If you would like to examine the namespace after
        the test completes, then use `clear_globs=False`.

        `compileflags` gives the set of flags that should be used by
        the Python compiler when running the examples.  If not
        specified, then it will default to the set of future-import
        flags that apply to `globs`.

        The output of each example is checked using
        `DocTestRunner.check_output`, and the results are formatted by
        the `DocTestRunner.report_*` methods.
        N(RR+R2R.R=R�twriteRR�R�R�R'tresetR�R�R@t*_DocTestRunner__patched_linecache_getlinestdisplayhookt__displayhook__t_DocTestRunner__runtclear(RkRR+R�tclear_globsR�tsave_set_tracetsave_displayhook((s/usr/lib64/python2.7/doctest.pytruncs.			
				c
Cs |dkr|j}ng}g}g}d}}x�|jj�D]�}|\}\}	}
|	|
ksnt�||
7}||	7}|
dkr�|j|�qD|	dkr�|j||
f�qD|j|�qDW|r^|rt|�GdGH|j�x|D]}dG|GHq�Wn|r^t|�GdGH|j�x&|D]\}}d||fGHq9Wq^n|r�|jGHt|�GdGH|j�x/|D]$\}\}	}
d|	|
|fGHq�Wn|r�|GdGt|j�Gd	GH||Gd
G|GdGHn|rdG|Gd
GHn|rdGHnt	||�S(s�
        Print a summary of all the test cases that have been run by
        this DocTestRunner, and return a tuple `(f, t)`, where `f` is
        the total number of failed examples, and `t` is the total
        number of tried examples.

        The optional `verbose` argument controls how detailed the
        summary is.  If the verbosity is not specified, then the
        DocTestRunner's verbosity is used.
        isitems had no tests:s   sitems passed all tests:s %3d tests in %ssitems had failures:s %3d of %3d in %sstests insitems.s
passed andsfailed.s***Test Failed***s	failures.sTest passed.N(
R+R�RR�RtR�R&R�R$R#(
RkR�tnoteststpassedtfailedttotaltttotalfR�R'RRR8tthingR�((s/usr/lib64/python2.7/doctest.pyt	summarize�sR






cCsv|j}xf|jj�D]U\}\}}||kr^||\}}||}||}n||f||<qWdS(N(RR�(RkR�tdR'RRR8R9R:((s/usr/lib64/python2.7/doctest.pytmerge�s	"

N(R4RqR�R$R+R�RRR!R"RRHR*RYR�R=RERxRMRTRV(((s/usr/lib64/python2.7/doctest.pyR8s7
$	
					|	
>9cBs)eZdZd�Zd�Zd�ZRS(s_
    A class used to check the whether the actual output from a doctest
    example matches the expected output.  `OutputChecker` defines two
    methods: `check_output`, which compares a given pair of outputs,
    and returns true if they match; and `output_difference`, which
    returns a string describing the differences between two outputs.
    cCs||krtS|t@sI||fd	kr0tS||fd
krItSn|t@s�tjdtjt�d|�}tjdd|�}||kr�tSn|t@r�dj|j	��}dj|j	��}||kr�tSn|t
@rt||�rtSntS(s�
        Return True iff the actual output from an example (`got`)
        matches the expected output (`want`).  These strings are
        always considered to match if they are identical; but
        depending on what option flags the test runner is using,
        several non-exact match types are also possible.  See the
        documentation for `TestRunner` for more information about
        option flags.
        sTrue
s1
sFalse
s0
s(?m)^%s\s*?$Rms
(?m)^\s*?$RV(sTrue
s1
(sFalse
s0
(
RxRRRYRZtescapetBLANKLINE_MARKERRR�RsRRRv(RkRyRzR((s/usr/lib64/python2.7/doctest.pyR&�s,



cCsL|ttBtB@stS|t@r$tS|jd�dkoK|jd�dkS(Ns
i(RR	R
RvRxR�(RkRyRzR((s/usr/lib64/python2.7/doctest.pyt_do_a_fancy_diff%s
cCs�|j}|t@s+tjdt|�}n|j|||�rd|jt�}|jt�}|t@r�t	j
||dd�}t|�d}d}n�|t@r�t	j
||dd�}t|�d}d}nR|t@rt	jdt	j�}	t|	j||��}d}nds&td	��g|D]}
|
j�d
^q-}d|tdj|��S|r�|r�d
t|�t|�fS|r�dt|�S|r�dt|�SdSdS(s�
        Return a string describing the differences between the
        expected output for a given example (`example`) and the actual
        output (`got`).  `optionflags` is the set of option flags used
        to compare `want` and `got`.
        s(?m)^[ ]*(?=
)tnis#unified diff with -expected +actuals-context diff with expected followed by actualtcharjunksndiff with -expected +actualisBad diff options
sDifferences (%s):
RmsExpected:
%sGot:
%ssExpected:
%sGot nothing
sExpected nothing
Got:
%ssExpected nothing
Got nothing
N(RyRRYRZRXRYR?RxRtdifflibtunified_difftlistR	tcontext_diffR
tDiffertIS_CHARACTER_JUNKtcompareRtR�R]R�(RkRRzRRyR�t	got_linestdifftkindtengineR�((s/usr/lib64/python2.7/doctest.pyR <s8	

	
	
	#(R4RqR�R&RYR (((s/usr/lib64/python2.7/doctest.pyR�s	6	cBs eZdZd�Zd�ZRS(s�A DocTest example has failed in debugging mode.

    The exception instance has variables:

    - test: the DocTest object being run

    - example: the Example object that failed

    - got: the actual output
    cCs||_||_||_dS(N(RRRz(RkRRRz((s/usr/lib64/python2.7/doctest.pyR�ws		cCs
t|j�S(N(R8R(Rk((s/usr/lib64/python2.7/doctest.pyt__str__|s(R4RqR�R�Rg(((s/usr/lib64/python2.7/doctest.pyRls
	cBs eZdZd�Zd�ZRS(s�A DocTest example has encountered an unexpected exception

    The exception instance has variables:

    - test: the DocTest object being run

    - example: the Example object that failed

    - exc_info: the exception info
    cCs||_||_||_dS(N(RRRb(RkRRRb((s/usr/lib64/python2.7/doctest.pyR��s		cCs
t|j�S(N(R8R(Rk((s/usr/lib64/python2.7/doctest.pyRg�s(R4RqR�R�Rg(((s/usr/lib64/python2.7/doctest.pyRs
	cBs2eZdZdded�Zd�Zd�ZRS(s{	Run doc tests but raise an exception as soon as there is a failure.

       If an unexpected exception occurs, an UnexpectedException is raised.
       It contains the test, the example, and the original exception:

         >>> runner = DebugRunner(verbose=False)
         >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42',
         ...                                    {}, 'foo', 'foo.py', 0)
         >>> try:
         ...     runner.run(test)
         ... except UnexpectedException, failure:
         ...     pass

         >>> failure.test is test
         True

         >>> failure.example.want
         '42\n'

         >>> exc_info = failure.exc_info
         >>> raise exc_info[0], exc_info[1], exc_info[2]
         Traceback (most recent call last):
         ...
         KeyError

       We wrap the original exception to give the calling application
       access to the test and example information.

       If the output doesn't match, then a DocTestFailure is raised:

         >>> test = DocTestParser().get_doctest('''
         ...      >>> x = 1
         ...      >>> x
         ...      2
         ...      ''', {}, 'foo', 'foo.py', 0)

         >>> try:
         ...    runner.run(test)
         ... except DocTestFailure, failure:
         ...    pass

       DocTestFailure objects provide access to the test:

         >>> failure.test is test
         True

       As well as to the example:

         >>> failure.example.want
         '2\n'

       and the actual output:

         >>> failure.got
         '1\n'

       If a failure or error occurs, the globals are left intact:

         >>> del test.globs['__builtins__']
         >>> test.globs
         {'x': 1}

         >>> test = DocTestParser().get_doctest('''
         ...      >>> x = 2
         ...      >>> raise KeyError
         ...      ''', {}, 'foo', 'foo.py', 0)

         >>> runner.run(test)
         Traceback (most recent call last):
         ...
         UnexpectedException: <DocTest foo from foo.py:0 (2 examples)>

         >>> del test.globs['__builtins__']
         >>> test.globs
         {'x': 2}

       But the globals are cleared if there is no error:

         >>> test = DocTestParser().get_doctest('''
         ...      >>> x = 2
         ...      ''', {}, 'foo', 'foo.py', 0)

         >>> runner.run(test)
         TestResults(failed=0, attempted=1)

         >>> test.globs
         {}

       cCs5tj||||t�}|r1|jj�n|S(N(RRMRvR.RI(RkRR+R�RJtr((s/usr/lib64/python2.7/doctest.pyRM�scCst|||��dS(N(R(RkR�RRRb((s/usr/lib64/python2.7/doctest.pyR"�scCst|||��dS(N(R(RkR�RRRz((s/usr/lib64/python2.7/doctest.pyR!�sN(R4RqR�R+RxRMR"R!(((s/usr/lib64/python2.7/doctest.pyR�sY	ic	Cs|dkr!tjjd�}ntj|�sFtd|f��n|dkr^|j}ntd|�}	|r�t	d|d|�}
nt
d|d|�}
x3|	j||d|d|�D]}|
j|�q�W|r�|
j
�ntdkr�|
an
tj|
�t|
j|
j�S(	s*
m=None, name=None, globs=None, verbose=None, report=True,
       optionflags=0, extraglobs=None, raise_on_error=False,
       exclude_empty=False

    Test examples in docstrings in functions and classes reachable
    from module m (or the current module if m is not supplied), starting
    with m.__doc__.

    Also test examples reachable from dict m.__test__ if it exists and is
    not None.  m.__test__ maps names to functions, classes and strings;
    function and class docstrings are tested even if the name is private;
    strings are tested directly, as if they were docstrings.

    Return (#failures, #tests).

    See help(doctest) for an overview.

    Optional keyword arg "name" gives the name of the module; by default
    use m.__name__.

    Optional keyword arg "globs" gives a dict to be used as the globals
    when executing examples; by default, use m.__dict__.  A copy of this
    dict is actually used for each docstring, so that each docstring's
    examples start with a clean slate.

    Optional keyword arg "extraglobs" gives a dictionary that should be
    merged into the globals that are used to execute examples.  By
    default, no extra globals are used.  This is new in 2.4.

    Optional keyword arg "verbose" prints lots of stuff if true, prints
    only failures if false; by default, it's true iff "-v" is in sys.argv.

    Optional keyword arg "report" prints a summary at the end when true,
    else prints nothing at the end.  In verbose mode, the summary is
    detailed, else very brief (in fact, empty if all tests passed).

    Optional keyword arg "optionflags" or's together module constants,
    and defaults to 0.  This is new in 2.3.  Possible values (see the
    docs for details):

        DONT_ACCEPT_TRUE_FOR_1
        DONT_ACCEPT_BLANKLINE
        NORMALIZE_WHITESPACE
        ELLIPSIS
        SKIP
        IGNORE_EXCEPTION_DETAIL
        REPORT_UDIFF
        REPORT_CDIFF
        REPORT_NDIFF
        REPORT_ONLY_FIRST_FAILURE

    Optional keyword arg "raise_on_error" raises an exception on the
    first unexpected exception or failure. This allows failures to be
    post-mortem debugged.

    Advanced tomfoolery:  testmod runs methods of a local instance of
    class doctest.Tester, then merges the results into (or creates)
    global Tester instance doctest.master.  Methods of doctest.master
    can be called directly too, if you want to do something unusual.
    Passing report=0 to testmod is especially useful then, to delay
    displaying a summary.  Invoke doctest.master.summarize(verbose)
    when you're done fiddling.
    R�stestmod: module required; %rR�R�RR.R�N(R+R=R>R*R5R6RAR4RRRRwRMRTtmasterRVR#RR(R�R'R.R�treportRR�traise_on_errorR�tfindertrunnerR((s/usr/lib64/python2.7/doctest.pyRs$E%
	
cCsl|r|rtd��nt|||�\}}|dkrUtjj|�}n|dkrji}n|j�}|dk	r�|j|�nd|kr�d|d<n|	r�td|d|�}
nt	d|d|�}
|dk	r�|j
|�}n|
j||||d�}|
j|�|r7|
j
�ntdkrL|
an
tj|
�t|
j|
j�S(s


    Test examples in the given file.  Return (#failures, #tests).

    Optional keyword arg "module_relative" specifies how filenames
    should be interpreted:

      - If "module_relative" is True (the default), then "filename"
         specifies a module-relative path.  By default, this path is
         relative to the calling module's directory; but if the
         "package" argument is specified, then it is relative to that
         package.  To ensure os-independence, "filename" should use
         "/" characters to separate path segments, and should not
         be an absolute path (i.e., it may not begin with "/").

      - If "module_relative" is False, then "filename" specifies an
        os-specific path.  The path may be absolute or relative (to
        the current working directory).

    Optional keyword arg "name" gives the name of the test; by default
    use the file's basename.

    Optional keyword argument "package" is a Python package or the
    name of a Python package whose directory should be used as the
    base directory for a module relative filename.  If no package is
    specified, then the calling module's directory is used as the base
    directory for module relative filenames.  It is an error to
    specify "package" if "module_relative" is False.

    Optional keyword arg "globs" gives a dict to be used as the globals
    when executing examples; by default, use {}.  A copy of this dict
    is actually used for each docstring, so that each docstring's
    examples start with a clean slate.

    Optional keyword arg "extraglobs" gives a dictionary that should be
    merged into the globals that are used to execute examples.  By
    default, no extra globals are used.

    Optional keyword arg "verbose" prints lots of stuff if true, prints
    only failures if false; by default, it's true iff "-v" is in sys.argv.

    Optional keyword arg "report" prints a summary at the end when true,
    else prints nothing at the end.  In verbose mode, the summary is
    detailed, else very brief (in fact, empty if all tests passed).

    Optional keyword arg "optionflags" or's together module constants,
    and defaults to 0.  Possible values (see the docs for details):

        DONT_ACCEPT_TRUE_FOR_1
        DONT_ACCEPT_BLANKLINE
        NORMALIZE_WHITESPACE
        ELLIPSIS
        SKIP
        IGNORE_EXCEPTION_DETAIL
        REPORT_UDIFF
        REPORT_CDIFF
        REPORT_NDIFF
        REPORT_ONLY_FIRST_FAILURE

    Optional keyword arg "raise_on_error" raises an exception on the
    first unexpected exception or failure. This allows failures to be
    post-mortem debugged.

    Optional keyword arg "parser" specifies a DocTestParser (or
    subclass) that should be used to extract tests from the files.

    Optional keyword arg "encoding" specifies an encoding that should
    be used to convert the file to unicode.

    Advanced tomfoolery:  testmod runs methods of a local instance of
    class doctest.Tester, then merges the results into (or creates)
    global Tester instance doctest.master.  Methods of doctest.master
    can be called directly too, if you want to do something unusual.
    Passing report=0 to testmod is especially useful then, to delay
    displaying a summary.  Invoke doctest.master.summarize(verbose)
    when you're done fiddling.
    s8Package may only be specified for module-relative paths.R4R�R�RiN(R�RSR+RJR�tbasenameR�R�RRtdecodeR�RMRTRiRVR#RR(RNRPR'ROR.R�RjRR�RkR�RTttextRmR((s/usr/lib64/python2.7/doctest.pyRjs2R
	


	
tNoNamec	Csdtd|dt�}td|d|�}x3|j||d|�D]}|j|d|�qCWdS(sr
    Test examples in the given object's docstring (`f`), using `globs`
    as globals.  Optional argument `name` is used in failure messages.
    If the optional argument `verbose` is true, then generate output
    even if there are no failures.

    `compileflags` gives the set of flags that should be used by the
    Python compiler when running the examples.  If not specified, then
    it will default to the set of future-import flags that apply to
    `globs`.

    Optional keyword arg `optionflags` specifies options for the
    testing and output.  See the documentation for `testmod` for more
    information.
    R�R�RR.R+N(RRvRRwRM(	RRR.R�R'R+RRlRmR((s/usr/lib64/python2.7/doctest.pyR�scBs_eZddddd�Zd�Zddd�Zdd�Zd�Zdd�Zd�Z	RS(	icCs�tjdtdd�|dkr=|dkr=td��n|dk	rotj|�rotd|f��n|dkr�|j}n||_||_	||_
t�|_t
d|d|�|_dS(NsCclass Tester is deprecated; use class doctest.DocTestRunner insteadt
stacklevelis*Tester.__init__: must specify mod or globss)Tester.__init__: mod must be a module; %rR�R(twarningstwarntDeprecationWarningR+RAR5R6R�R.R�RRt
testfinderRt
testrunner(RktmodR.R�R((s/usr/lib64/python2.7/doctest.pyR�s	
			cCs|t�j||j|dd�}|jr6dG|GHn|jj|�\}}|jro|GdG|GdG|GHnt||�S(NsRunning stringtofsexamples failed in string(RR�R.R+R�RwRMR#(RkR[R'RRRR8((s/usr/lib64/python2.7/doctest.pyt	runstrings!		c
Csyd}}|jj||d|d|j�}x;|D]3}|jj|�\}}	||||	}}q5Wt||�S(NiRBR.(RvRwR.RwRMR#(
RkR�R'RBRRR8R�RR9R:((s/usr/lib64/python2.7/doctest.pytrundoc"s

cCsSddl}|j|�}|jj|�|dkr@t}n|j|||�S(Ni����(ttypest
ModuleTypeR�R�R+RvR{(RkRUR'RBR|R�((s/usr/lib64/python2.7/doctest.pytrundict+s	cCs4ddl}|j|�}||_|j||�S(Ni����(R|R}R�R{(RkRUR'R|R�((s/usr/lib64/python2.7/doctest.pytrun__test__3s	cCs|jj|�S(N(RwRT(RkR�((s/usr/lib64/python2.7/doctest.pyRT9scCs|jj|j�dS(N(RwRV(RkR�((s/usr/lib64/python2.7/doctest.pyRV<sN(
R4RqR+R�RzR{R~RRTRV(((s/usr/lib64/python2.7/doctest.pyRs				cCs2|t@|kr"td|��nt}|a|S(s?Sets the unittest option flags.

    The old flag is returned so that a runner could restore the old
    value if it wished to:

      >>> import doctest
      >>> old = doctest._unittest_reportflags
      >>> doctest.set_unittest_reportflags(REPORT_NDIFF |
      ...                          REPORT_ONLY_FIRST_FAILURE) == old
      True

      >>> doctest._unittest_reportflags == (REPORT_NDIFF |
      ...                                   REPORT_ONLY_FIRST_FAILURE)
      True

    Only reporting flags can be set:

      >>> doctest.set_unittest_reportflags(ELLIPSIS)
      Traceback (most recent call last):
      ...
      ValueError: ('Only reporting flags allowed', 8)

      >>> doctest.set_unittest_reportflags(old) == (REPORT_NDIFF |
      ...                                   REPORT_ONLY_FIRST_FAILURE)
      True
    sOnly reporting flags allowed(RR�t_unittest_reportflags(R/told((s/usr/lib64/python2.7/doctest.pyREs
tDocTestCasecBs�eZdd
d
d
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
e
Zd�ZRS(icCsAtjj|�||_||_||_||_||_dS(N(tunittesttTestCaseR�t_dt_optionflagst_dt_checkert_dt_testt	_dt_setUpt_dt_tearDown(RkRRtsetUpttearDownR((s/usr/lib64/python2.7/doctest.pyR�ks				cCs,|j}|jdk	r(|j|�ndS(N(R�R�R+(RkR((s/usr/lib64/python2.7/doctest.pyR�us	cCs9|j}|jdk	r(|j|�n|jj�dS(N(R�R�R+R.RI(RkR((s/usr/lib64/python2.7/doctest.pyR�{s	cCs�|j}tj}t�}|j}|t@s;|tO}ntd|d|jdt	�}z5dd|_
|j|d|jdt	�\}}Wd|t_X|r�|j
|j|j����ndS(NRRR�R
iFR�RJ(R�R=R�R!R�RR�RR�RvR$RMRCtfailureExceptiontformat_failureRa(RkRR�tnewRRmRR((s/usr/lib64/python2.7/doctest.pytrunTest�s				


"
cCsj|j}|jdkr!d}n
d|j}dj|jjd�d�}d|j|j|||fS(Nsunknown line numbers%sR�i����s:Failed doctest test for %s
  File "%s", line %s, in %s

%s(R�R�R+R�R'RsRN(RkterrRR�tlname((s/usr/lib64/python2.7/doctest.pyR��s		
cCsO|j�td|jd|jdt�}|j|jdt�|j�dS(s�Run the test case without results and without catching exceptions

           The unit test framework includes a debug method on test cases
           and test suites to support post-mortem debugging.  The test code
           is run in such a way that errors are not caught.  This way a
           caller can catch the errors and initiate post-mortem debugging.

           The DocTestCase provides a debug method that raises
           UnexpectedException errors if there is an unexpected
           exception:

             >>> test = DocTestParser().get_doctest('>>> raise KeyError\n42',
             ...                {}, 'foo', 'foo.py', 0)
             >>> case = DocTestCase(test)
             >>> try:
             ...     case.debug()
             ... except UnexpectedException, failure:
             ...     pass

           The UnexpectedException contains the test, the example, and
           the original exception:

             >>> failure.test is test
             True

             >>> failure.example.want
             '42\n'

             >>> exc_info = failure.exc_info
             >>> raise exc_info[0], exc_info[1], exc_info[2]
             Traceback (most recent call last):
             ...
             KeyError

           If the output doesn't match, then a DocTestFailure is raised:

             >>> test = DocTestParser().get_doctest('''
             ...      >>> x = 1
             ...      >>> x
             ...      2
             ...      ''', {}, 'foo', 'foo.py', 0)
             >>> case = DocTestCase(test)

             >>> try:
             ...    case.debug()
             ... except DocTestFailure, failure:
             ...    pass

           DocTestFailure objects provide access to the test:

             >>> failure.test is test
             True

           As well as to the example:

             >>> failure.example.want
             '2\n'

           and the actual output:

             >>> failure.got
             '1\n'

           RRR�RJN(R�RR�R�RvRMR�R�(RkRm((s/usr/lib64/python2.7/doctest.pyR �s
B
cCs
|jjS(N(R�R'(Rk((s/usr/lib64/python2.7/doctest.pyR��scCstt|�t|�k	rtS|j|jkos|j|jkos|j|jkos|j|jkos|j|jkS(N(R�R�R�R�R�R�R�(RkR�((s/usr/lib64/python2.7/doctest.pyR��scCs||kS(N((RkR�((s/usr/lib64/python2.7/doctest.pyR��scCs"t|j|j|j|jf�S(N(R�R�R�R�R�(Rk((s/usr/lib64/python2.7/doctest.pyR��scCs4|jjjd�}d|ddj|d �fS(NR�s%s (%s)i����(R�R'RsR�(RkR'((s/usr/lib64/python2.7/doctest.pyR�	scCsd|jjS(Ns	Doctest: (R�R'(Rk((s/usr/lib64/python2.7/doctest.pytshortDescription		sN(R4RqR+R�R�R�R�R�R R�R�R�R�R�RgR�(((s/usr/lib64/python2.7/doctest.pyR�is							H		
			tSkipDocTestCasecBs2eZd�Zd�Zd�Zd�ZeZRS(cCs||_tj|d�dS(N(RBR�R�R+(RkRB((s/usr/lib64/python2.7/doctest.pyR�
	s	cCs|jd�dS(Ns-DocTestSuite will not work with -O2 and above(tskipTest(Rk((s/usr/lib64/python2.7/doctest.pyR�	scCsdS(N((Rk((s/usr/lib64/python2.7/doctest.pyt	test_skip	scCsd|jjS(NsSkipping tests from %s(RBR4(Rk((s/usr/lib64/python2.7/doctest.pyR�	s(R4RqR�R�R�R�Rg(((s/usr/lib64/python2.7/doctest.pyR�	s
				c	Ks*|d
krt�}nt|�}|j|d|d|�}|r{tjjdkr{tj�}|j	t
|��|S|s�t|d��n|j�tj�}xz|D]r}t
|j�dkr�q�n|js|j}|ddkr|d	 }n||_n|j	t||��q�W|S(s
    Convert doctest tests for a module to a unittest test suite.

    This converts each documentation string in a module that
    contains doctest tests to a unittest test case.  If any of the
    tests in a doc string fail, then the test case fails.  An exception
    is raised showing the name of the file containing the test and a
    (sometimes approximate) line number.

    The `module` argument provides the module to be tested.  The argument
    can be either a module or a module name.

    If no argument is given, the calling module is used.

    A number of options may be provided as keyword arguments:

    setUp
      A set-up function.  This is called before running the
      tests in each file. The setUp function will be passed a DocTest
      object.  The setUp function can access the test globals as the
      globs attribute of the test passed.

    tearDown
      A tear-down function.  This is called after running the
      tests in each file.  The tearDown function will be passed a DocTest
      object.  The tearDown function can access the test globals as the
      globs attribute of the test passed.

    globs
      A dictionary containing initial global variables for the tests.

    optionflags
       A set of doctest option flags expressed as an integer.
    R.R�ishas no docstringsii����s.pycs.pyoi����N(s.pycs.pyo(R+RRDRwR=R/toptimizeR�t	TestSuitetaddTestR�R�R�R&R�RNR�R�(	RBR.R�ttest_finderR�R�tsuiteRRN((s/usr/lib64/python2.7/doctest.pyR	s,%

		
tDocFileCasecBs)eZd�Zd�ZeZd�ZRS(cCsdj|jjjd��S(Nt_R�(R�R�R'Rs(Rk((s/usr/lib64/python2.7/doctest.pyR�h	scCs
|jjS(N(R�RN(Rk((s/usr/lib64/python2.7/doctest.pyR�k	scCsd|jj|jj|fS(Ns2Failed doctest test for %s
  File "%s", line 0

%s(R�R'RN(RkR�((s/usr/lib64/python2.7/doctest.pyR�o	s(R4RqR�R�RgR�(((s/usr/lib64/python2.7/doctest.pyR�f	s		c
Ks�|dkri}n|j�}|r=|r=td��nt|||�\}}d|krn||d<ntjj|�}|dk	r�|j|�}n|j||||d�}	t	|	|�S(Ns8Package may only be specified for module-relative paths.R�i(
R+R�R�RSRJR�RnRoR�R�(
R�RPROR.R�RTR�tdocR'R((s/usr/lib64/python2.7/doctest.pytDocFileTestt	s	

cOsetj�}|jdt�r:t|jd��|d<nx$|D]}|jt||��qAW|S(s�A unittest suite for one or more doctest files.

    The path to each doctest file is given as a string; the
    interpretation of that string depends on the keyword argument
    "module_relative".

    A number of options may be provided as keyword arguments:

    module_relative
      If "module_relative" is True, then the given file paths are
      interpreted as os-independent module-relative paths.  By
      default, these paths are relative to the calling module's
      directory; but if the "package" argument is specified, then
      they are relative to that package.  To ensure os-independence,
      "filename" should use "/" characters to separate path
      segments, and may not be an absolute path (i.e., it may not
      begin with "/").

      If "module_relative" is False, then the given file paths are
      interpreted as os-specific paths.  These paths may be absolute
      or relative (to the current working directory).

    package
      A Python package or the name of a Python package whose directory
      should be used as the base directory for module relative paths.
      If "package" is not specified, then the calling module's
      directory is used as the base directory for module relative
      filenames.  It is an error to specify "package" if
      "module_relative" is False.

    setUp
      A set-up function.  This is called before running the
      tests in each file. The setUp function will be passed a DocTest
      object.  The setUp function can access the test globals as the
      globs attribute of the test passed.

    tearDown
      A tear-down function.  This is called after running the
      tests in each file.  The tearDown function will be passed a DocTest
      object.  The tearDown function can access the test globals as the
      globs attribute of the test passed.

    globs
      A dictionary containing initial global variables for the tests.

    optionflags
      A set of doctest option flags expressed as an integer.

    parser
      A DocTestParser (or subclass) that should be used to extract
      tests from the files.

    encoding
      An encoding that will be used to convert the files to unicode.
    RPRO(R�R�R*RxRDR�R�(tpathstkwR�R�((s/usr/lib64/python2.7/doctest.pyR�	s8
cCs(g}x�t�j|�D]�}t|t�r�|j|jd �|j}|r�|jd�|g|jd�d D]}d|^qu7}q�q|g|jd�d D]}t|�^q�7}qWx$|r�|ddkr�|j	�q�Wx'|r|ddkr|j	d�q�Wdj
|�dS(svExtract script from text with examples.

       Converts text with examples to a Python script.  Example input is
       converted to regular code.  Example output and all other words
       are converted to comments:

       >>> text = '''
       ...       Here are examples of simple math.
       ...
       ...           Python has super accurate integer addition
       ...
       ...           >>> 2 + 2
       ...           5
       ...
       ...           And very friendly error messages:
       ...
       ...           >>> 1/0
       ...           To Infinity
       ...           And
       ...           Beyond
       ...
       ...           You can use logic if you want:
       ...
       ...           >>> if 0:
       ...           ...    blah
       ...           ...    blah
       ...           ...
       ...
       ...           Ho hum
       ...           '''

       >>> print script_from_examples(text)
       # Here are examples of simple math.
       #
       #     Python has super accurate integer addition
       #
       2 + 2
       # Expected:
       ## 5
       #
       #     And very friendly error messages:
       #
       1/0
       # Expected:
       ## To Infinity
       ## And
       ## Beyond
       #
       #     You can use logic if you want:
       #
       if 0:
          blah
          blah
       #
       #     Ho hum
       <BLANKLINE>
       i����s# Expected:s
s## R�i(RR�R7R
R�R�RyRsR�tpopR�(R[R�tpieceRyR�((s/usr/lib64/python2.7/doctest.pyR�	s:	
4.cCs{t|�}t�j|�}g|D]}|j|kr%|^q%}|s^t|d��n|d}t|j�}|S(sExtract the test sources from a doctest docstring as a script.

    Provide the module (or dotted name of the module) containing the
    test to be debugged and the name (within the module) of the object
    with the doc string with tests to be debugged.
    snot found in testsi(RDRRwR'R�RR�(RBR'R�R8Rttestsrc((s/usr/lib64/python2.7/doctest.pyR,
s(
cCs t|�}t|||�dS(s4Debug a single doctest docstring, in argument `src`'N(Rtdebug_script(tsrctpmR.R�((s/usr/lib64/python2.7/doctest.pyR<
scCs�ddl}tjdd�}t|d�}|j|�|j�z�|r\|j�}ni}|r�yt|||�Wq�tj	�dGH|j
tj	�d�q�Xn|jd|||�Wdtj
|�XdS(	s7Debug a test script.  `src` is the script, as a string.i����Ns.pytdoctestdebugR~iisexecfile(%r)(R�ttempfiletmktempRLRCtcloseR�texecfileR=Rbtpost_mortemRMRJtremove(R�R�R.R�tsrcfilenameRR((s/usr/lib64/python2.7/doctest.pyR�A
s"

cCs2t|�}t||�}t|||j�dS(s�Debug a single doctest docstring.

    Provide the module (or dotted name of the module) containing the
    test to be debugged and the name (within the module) of the object
    with the docstring with tests to be debugged.
    N(RDRR�R�(RBR'R�R�((s/usr/lib64/python2.7/doctest.pyR a
st
_TestClasscBs)eZdZd�Zd�Zd�ZRS(s�
    A pointless class, for sanity-checking of docstring testing.

    Methods:
        square()
        get()

    >>> _TestClass(13).get() + _TestClass(-12).get()
    1
    >>> hex(_TestClass(13).square().get())
    '0xa9'
    cCs
||_dS(s�val -> _TestClass object with associated value val.

        >>> t = _TestClass(123)
        >>> print t.get()
        123
        N(R(RkR((s/usr/lib64/python2.7/doctest.pyR�}
scCs|jd|_|S(sosquare() -> square TestClass's associated value

        >>> _TestClass(13).square().get()
        169
        i(R(Rk((s/usr/lib64/python2.7/doctest.pytsquare�
scCs|jS(s}get() -> return TestClass's associated value.

        >>> x = _TestClass(-42)
        >>> print x.get()
        -42
        (R(Rk((s/usr/lib64/python2.7/doctest.pyR*�
s(R4RqR�R�R�R*(((s/usr/lib64/python2.7/doctest.pyR�o
s	
	
s�
                      Example of a string object, searched as-is.
                      >>> x = 1; y = 2
                      >>> x + y, x * y
                      (3, 2)
                      R�s�
                                    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
                                    sbool-int equivalences�
                Blank lines can be marked with <BLANKLINE>:
                    >>> print 'foo\n\nbar\n'
                    foo
                    <BLANKLINE>
                    bar
                    <BLANKLINE>
            sblank liness�
                If the ellipsis flag is used, then '...' can be used to
                elide substrings in the desired output:
                    >>> print range(1000) #doctest: +ELLIPSIS
                    [0, 1, 2, ..., 999]
            tellipsiss|
                If the whitespace normalization flag is used, then
                differences in whitespace are ignored.
                    >>> print 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]
            swhitespace normalizationcCs1gtjdD]"}|r|ddkr|^q}|s�tjjtjd�}dt�krtjj|�\}}ndj|�GHdSx�|D]�}|jd�rtjj	|�\}}tjj
d|�t|d �}tjd=t|�\}}nt
|d	t�\}}|r�dSq�WdS(
NiiR
REsusage: {0} [-v] file ...is.pyi����RP(R=R�RJR�RnR;tsplitexttformatRjRstinsertR:RRRv(targt	testfilesR'R�RNtdirnameR�R((s/usr/lib64/python2.7/doctest.pyt_test�
s$6

R�(VR�t
__docformat__t__all__R(R=R_R5R�RJRYR�R\R�R�RsR!tcollectionsR"R#R$RRRRRRRRRR	R
RRRXRrR2RDRSR,t
__stdout__R+RXR]RgRhRR�R�R�RGR
RRRRRt	ExceptionRRRRiRxRvRRRRR�RR�R�R�RR�R�RRRRR�R R�R�R�R4texit(((s/usr/lib64/python2.7/doctest.pyt<module>.s�	H0					1	$	$HL��)���n	f	z?	$�I		I	R	 ,