Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�9�c!@sGdZdZdddddddd	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%lmZejd&deed'�iZd(�Zed�Zed�Zed�Zed�Zed�ZeeBeBeBeBZed	�Zed
�Zed�Zed�ZeeBeBeBZd)Z d*Z!d+�Z"d,�Z#d-d.�Z$d/d0�Z%d1�Z&d2efd3��YZ'd4�Z(d5�Z)d6ej*fd7��YZ+d8�Z,dfd9��YZ-dfd:��YZ.dfd;��YZ/dfd<��YZ0dfd=��YZ1dfd>��YZ2de3fd?��YZ4de3fd@��YZ5de1fdA��YZ6e7a8e7e7e7e7e7e9d'e7e:e:dB�Z;e9e7e7e7e7e9d'e7e:e/�dC�Z<e:dDe7d'dE�Z=dfdF��YZ>d'a?dG�Z@dHe
jAfdI��YZBe7e7e7e7dJ�ZCdKeBfdL��YZDe9e7e7e/�dM�ZEdN�ZFdO�ZGdP�ZHe:e7dQ�ZIe:e7dR�ZJe:dS�ZKiZLd$S(Ts�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_WHITESPACEtELLIPSIStIGNORE_EXCEPTION_DETAILtCOMPARISON_FLAGStREPORT_UDIFFtREPORT_CDIFFtREPORT_NDIFFtREPORT_ONLY_FIRST_FAILUREtREPORTING_FLAGSt
is_privatetExampletDocTestt
DocTestParsert
DocTestFindert
DocTestRunnert
OutputCheckertDocTestFailuretUnexpectedExceptiontDebugRunnerttestmodttestfiletrun_docstring_examplestTestertDocTestSuitetDocFileSuitetset_unittest_reportflagstscript_from_examplest
testsourcet	debug_srctdebugi�N(tStringIOtignoreicCstj|dtt�>�S(Ni(tOPTIONFLAGS_BY_NAMEt
setdefaulttlen(tname((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�ss<BLANKLINE>s...cCsItjdtdd�|d dkoH|d dkoE|dknS(s}prefix, base -> true iff name prefix + "." + base is "private".

    Prefix may be an empty string, and base does not contain a period.
    Prefix is ignored (although functions you write conforming to this
    protocol may make use of it).
    Return true iff base begins with an (at least one) underscore, but
    does not both begin and end with (at least) two underscores.
    sVis_private is deprecated; it wasn't useful; examine DocTestFinder.find() lists insteadt
stackleveliit_t__i�(twarningstwarntDeprecationWarning(tprefixtbase((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�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((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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__tglobalstlocalsR2tsystmodulest	_getframet	f_globalst	TypeError(tmoduletdepth((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_normalize_module�s
icCstjd|d|�S(s{
    Add the given number of space characters to the beginning every
    non-blank line in `s`, and return the result.
    s
(?m)^(?!$)t (tretsub(tstindent((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_exception_traceback�s	t	_SpoofOutcBseZd�Zdd�ZRS(cCsNtj|�}|r2|jd�r2|d7}nt|d�rJ|`n|S(Ns
t	softspace(R!RUtendswiththasattrR](tselftresult((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRU�s
	cCs,tj||�t|d�r(|`ndS(NR](R!ttruncateR_R](R`tsize((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRbsN(R;t
__module__RUR2Rb(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR\�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�tS(Niii�(	tELLIPSIS_MARKERtsplitR%tAssertionErrort
startswithtFalseR^tfindtTrue(twanttgottwststartpostendpostw((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_ellipsis_match
s2





cCs"|j�}|rd|SdSdS(s)Return a commented form of the given lines# t#N(trstrip(tline((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt
_comment_line9st_OutputRedirectingPdbcBs eZdZd�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.
    cCs||_tjj|�dS(N(t_OutputRedirectingPdb__outtpdbtPdbt__init__(R`tout((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{Gs	cGs=tj}|jt_ztjj||�SWd|t_XdS(N(RDtstdoutRxRyRzttrace_dispatch(R`targstsave_stdout((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR~Ks
	(R;Rdt__doc__R{R~(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRwAs	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__ts+Can't resolve paths relative to the module s (it has no __file__)(R<R=RHRht
ValueErrorR_tostpathRfR�R;R%RDtargvtcurdirtjoin(RIR�tbasedir((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_module_relative_pathVs( cBs#eZdZddddd�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
(R^R2tsourceRltlinenoRPtoptionstexc_msg(R`R�RlR�R�RPR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{�s


						N(R;RdR�R2R{(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR
zs"	cBs)eZdZd�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(
R>t
basestringRgtexamplest	docstringtcopyR5R&tfilenameR�(R`R�R5R&R�R�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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&R�R�(R`R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__repr__�s		cCsVt|t�sdSt|j|j|jt|�f|j|j|jt|�f�S(Ni�(R>RtcmpR&R�R�tid(R`tother((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__cmp__�s!(R;RdR�R{R�R�(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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�RPR�(ii(t
expandtabst_min_indentR�Rft_EXAMPLE_REtfinditertappendtstarttcountt_parse_examplet_IS_BLANK_OR_COMMENTR
R%tgrouptend(
R`tstringR&t
min_indenttltoutputtcharnoR�tmR�R�RlR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytparses&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(R`R�R5R&R�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytget_doctestBs	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�R>R
(R`R�R&tx((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�Nsc
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.
        RPR�s
iRLt.iRls *$i�tmsgN(R%R�Rft_check_prompt_blankt
_check_prefixR�RMtmatcht
_EXCEPTION_RER2t
_find_options(
R`R�R&R�RPtsource_linestslR�Rlt
want_linestwlR�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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�d|||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,RLis+-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�treplaceRfR#R�R�(	R`R�R&R�R�R�toption_stringstoptiontflag((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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(R`RORPtindents((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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.
        iiRLs8line %r of the docstring for %s lacks blank after %s: %riN(t	enumerateR%R�(R`tlinesRPR&R�tiRu((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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�RhR�(R`R�R-R&R�R�Ru((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR��s(R;RdR�RMtcompilet	MULTILINEtVERBOSER�tDOTALLR�R�R�R�R�R�R�R�R�R�R�R�R�(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s"'		3				cBskeZdZee�eded�Zddddd�Zd�Z	d�Z
d�Zd�Zd�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.
    cCs1||_||_||_||_||_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_emptyt_namefilter(R`tverbosetparsertrecurseR�t
exclude_empty((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{�s
				c		Csd|dkrIt|dd�}|dkrItdt|�f��qIn|tkr^d}n|dkr|tj|�}ny@tj|�p�tj|�}t	j
|�}|s�d}nWntk
r�d}nX|dkr	|dkr�}q|jj
�}n|j
�}|dk	r1|j|�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 {}.

        R;sJDocTestFinder.find: name must be given when obj.__name__ doesn't exist: %rN(R2R3R�ttypeRiR<t	getmodulet
getsourcefiletgetfilet	linecachetgetlinesRHt__dict__R�tupdatet_findtsort(	R`tobjR&RIR5t
extraglobsRRR�ttests((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRj�s6%	


	
cCs|jdk	o|j||�S(sI
        Return true if the given object should not be examined.
        N(R�R2(R`R�R-R.((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_filterLscCs�|dkrtStj|�r/|j|jkStj|�rW|jt|dd�kStj	|�dk	r|tj	|�kSt
|d�r�|j|jkSt|t
�r�tStd��dS(sY
        Return true if the given object is defined in the given
        module.
        Rds"object must be a class or functionN(R2RkR<t
isfunctionR�tfunc_globalstisclassR;R3R�R_RdR>tpropertyR�(R`RItobject((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt_from_moduleSscCs?|jrd|GHnt|�|kr+dSd|t|�<|j|||||�}|dk	rr|j|�ntj|�r*|jr*x�|jj	�D]�\}	}
|j
|
||	�r�q�nd||	f}	tj|
�s�j|
�r�|j
||
�r�|j||
|	||||�q�q�Wntj|�r/|jr/x�|di�j	�D]�\}	}
t|	t�s�tdt|	�f��ntj|
�p�tj|
�p�tj|
�p�tj|
�p�t|
t�s�dt|
�f��nd||	f}	|j||
|	||||�q[Wntj|�r;|jr;x�jj	�D]�\}	}
|j
|
||	�r~qWnt|
t�r�t||	�}
nt|
t�r�t||	�j}
ntj|
�s�j|
�s�|
t�rW|j
||
�rWd||	f}	|j||
|	||||�qWqWWndS(	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_testR2R�R<R=R�R�titemsR�R�R�R�R�R3R>R�R�R�tismethodtstaticmethodtclassmethodtim_funcR�(R`R�R�R&RIR�R5tseenttesttvalnametval((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�hsX	%c	Cs6t|t�r|}ncyC|jdkr3d}n'|j}t|t�sZt|�}nWnttfk
rzd}nX|j||�}|jr�|r�dS|dkr�d}ndt	|d|j
�}|ddkr�d }n2tjj
d�r|jd�rd	|d
 }n|jj|||||�S(
ss
        Return a DocTest for the given object, if it defines a docstring;
        otherwise, return None.
        R�R�i�s.pycs.pyoi�tjavas	$py.classs%s.pyi�N(s.pycs.pyo(R>R�R�R2R?RHtAttributeErrort_find_linenoR�R3R;RDtplatformRhR^R�R�(	R`R�R&RIR5R�R�R�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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\bR;t-tco_firstlinenois(^|.*:)\s*\w*("|')N(R2R<R=R�RMR�R3R�R�R�R�R�t	func_codetistracebackttb_frametisframetf_codetiscodetrangeR%(R`R�R�R�tpatR�Ru((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR��s<		N(R;RdR�RiRRkR2R{RjR�R�R�R�R�(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s		S			E	(cBs�eZddZdddd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zej
d�Zd�Zdded
�Zdd�Zd�ZRS(R:iFicCsv|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_checkerR2RDR�R�toptionflagstoriginal_optionflagsttriestfailurest_name2ftR\t_fakeout(R`tcheckerR�R((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{s						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�RlRQR�(R`R|R�texample((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytreport_start2s		(cCs|jr|d�ndS(st
        Report that the given example ran successfully.  (Only
        displays a message if verbose=True)
        sok
N(R�(R`R|R�RRm((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytreport_success?s	cCs3||j||�|jj|||j��dS(s7
        Report that the given example failed.
        N(t_failure_headerRtoutput_differenceR(R`R|R�RRm((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytreport_failureGscCs.||j||�dtt|���dS(sO
        Report that the given example raised an unexpected exception.
        sException raised:
N(RRQR[(R`R|R�RRV((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytreport_unexpected_exceptionNscCs�|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
(	tDIVIDERR�R�R2R�R&R�RQR�(R`R�RR|R�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRUs		!
	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|d7}|
s�j	|||�nd|j
|f}y7e|j|d|d�|j
U|jj�d
}Wn3ek
rL�n ej�}|jj�nX|jj�}|jjd�|}|d
kr�|
|j||j�r�|}q�n�j�}ej|d �d}|
s�e|�7}n|jd
kr|	}n�|
|j||j�r6|}ns|je@r�ejd|j�}ejd|�}|r�|r�|
|jd�|jd�|j�r�|}q�n||kr�|
s_|j ||||�q_qD||kr|
s|j!||||�n|d7}qD||	krG|
s:|j"||||�n|d7}qDe#sDt$d	|f��qDW||_|j%|||�||fS(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�R
R�R�R
R&R�R�R5tdebuggertset_continueR2tKeyboardInterruptRDRVR
RURbRlRStformat_exception_onlyR[R�RRMR�R�RRRRiRgt_DocTestRunner__record_outcome(R`R�tcompileflagsR|RRRtSUCCESStFAILUREtBOOMtcheckt
examplenumRtquiett
optionflagR�R�t	exceptionRmtoutcomeRVR�tm1tm2((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__runis~
	
		



		
'


	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(R	R1R&RR(R`R�tftttf2tt2((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__record_outcome�ss3<doctest (?P<name>[\w\.]+)\[(?P<examplenum>\d+)\]>$cCss|jj|�}|rb|jd�|jjkrb|jjt|jd��}|jjt	�S|j
|�SdS(NR&R!(t%_DocTestRunner__LINECACHE_FILENAME_RER�R�R�R&R�tintR�t
splitlinesRktsave_linecache_getlines(R`R�R�R((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__patched_linecache_getlines�s
!cCs�||_|dkr't|j�}ntj}|dkrH|j}n|jt_tj	}t
|�|_|jj�|jj	t_	t
j|_|jt
_z|j|||�SWd|t_|t_	|jt
_|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(R�R2R9R5RDR}twriteR
Ryt	set_traceRwRtresetR�R�R1t*_DocTestRunner__patched_linecache_getlinest_DocTestRunner__runtclear(R`R�RR|tclear_globsR�tsave_set_trace((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytrun�s(			
		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�|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|rdGHn||fS(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(	R2R�R	R�RgR�R%R�R(
R`R�tnoteststpassedtfailedttotaltttotalfR�R&R)R*tthingR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt	summarize/sR






cCs�|j}xs|jj�D]b\}\}}||krkd|dGH||\}}||}||}n||f||<qWdS(Ns*** DocTestRunner.merge: 's$' in both testers; summing outcomes.(R	R�(R`R�tdR&R)R*R+R,((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytmergehs	"


N(R;RdRR2R{R
RRRRR7RRMR�R.R6RkR;RBRD(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR	s
$	
					x	
	9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�j|j	��}dj|j	��}||kr�Sn|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*?$R�s
(?m)^\s*?$RL(sTrue
s1
(sFalse
s0
(
RkRRRMRNtescapetBLANKLINE_MARKERRR�RfRRrRi(R`RlRmR((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{s,



cCsL|ttBtB@stS|t@r$tS|jd�dkoK|jd�dkS(Ns
i(RRR	RiRkR�(R`RlRmR((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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):
R�sExpected:
%sGot:
%ssExpected:
%sGot nothing
sExpected nothing
Got:
%ssExpected nothing
Got nothing
N(RlRRMRNRFRGR0RkRtdifflibtunified_difftlistRtcontext_diffR	tDiffertIS_CHARACTER_JUNKtcompareRgRtRQR�(R`RRmRRlR�t	got_linestdifftkindtengineRu((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s8	

	
	
	#(R;RdR�RRGR(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRss	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

    - excample: the Example object that failed

    - got: the actual output
    cCs||_||_||_dS(N(R�RRm(R`R�RRm((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{s		cCs
t|j�S(N(R?R�(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt__str__s(R;RdR�R{RU(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s
	cBs eZdZd�Zd�ZRS(s�A DocTest example has encountered an unexpected exception

    The exception instance has variables:

    - test: the DocTest object being run

    - excample: the Example object that failed

    - exc_info: the exception info
    cCs||_||_||_dS(N(R�RRV(R`R�RRV((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{s		cCs
t|j�S(N(R?R�(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRUs(R;RdR�R{RU(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRs
	cBs,eZdded�Zd�Zd�ZRS(cCs5tj||||t�}|r1|jj�n|S(N(RR;RiR5R8(R`R�RR|R9tr((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR; scCst|||��dS(N(R(R`R|R�RRV((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR&scCst|||��dS(N(R(R`R|R�RRm((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR)sN(R;RdR2RkR;RR(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRs	c

Cs@|d
k	rtjdt�n|d
kr@tjjd�}ntj|�set	d|f��n|d
kr}|j
}ntd|d|	�}
|r�td|d|�}nt
d|d|�}x3|
j||d|d	|�D]}|j|�q�|r|j�ntd
kr#|an
tj|�|j|jfS(s�m=None, name=None, globs=None, verbose=None, isprivate=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__.  Unless isprivate is specified, private names
    are not skipped.

    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 doctest.__doc__ 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
        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.

    Deprecated in Python 2.4:
    Optional keyword arg "isprivate" specifies a function used to
    determine whether a name is private.  The default function is
    treat all functions as public.  Optionally, "isprivate" can be
    set to doctest.is_private to skip over functions marked as private
    using the underscore naming convention; see its docs for details.

    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.
    sPthe isprivate argument is deprecated; examine DocTestFinder.find() lists insteadR�stestmod: module required; %rR�R�R�RR5R�N(R2R*R+R,RDRER1R<R=RHR;RRRRjR;RBtmasterRDRR(
R�R&R5R�t	isprivatetreportRR�traise_on_errorR�tfindertrunnerR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR5s*K	
%
	
cCsP|r|rtd��n|r@t|�}t||�}n|dkratjj|�}n|dkrvi}n|j�}|dk	r�|j|�n|	r�t	d|d|�}nt
d|d|�}t|�j�}|
j
||||d�}
|j|
�|r|j�ntdkr3|an
tj|�|j|jfS(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
        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.

    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.R�RiN(R�RKR�R2R�R�tbasenameR�R�RRtopentreadR�R;RBRWRDRR(R�tmodule_relativeR&tpackageR5R�RYRR�RZR�R\ROR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s0M
	

	
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�RR5RN(RRiRRjR;(	R)R5R�R&RRR[R\R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRscBsbeZdddddd�Zd�Zddd�Zdd�Zd�Zdd�Zd�Z	RS(	icCs�tjdtdd�|dkr=|dkr=td��n|dk	rotj|�rotd|f��n|dkr�|j}n||_||_	||_
||_td|�|_
td|d|�|_dS(	NsCclass Tester is deprecated; use class doctest.DocTestRunner insteadR'is*Tester.__init__: must specify mod or globss)Tester.__init__: mod must be a module; %rR�R�R(R*R+R,R2RHR<R=R�R5R�RXRRt
testfinderRt
testrunner(R`tmodR5R�RXR((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{=s 	
				cCsyt�j||j|dd�}|jr6dG|GHn|jj|�\}}|jro|GdG|GdG|GHn||fS(NsRunning stringtofsexamples failed in string(RR�R5R2R�RdR;(R`ROR&R�R)R*((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt	runstringSs!		c
Csvd}}|jj||d|d|j�}x;|D]3}|jj|�\}}	||||	}}q5W||fS(NiRIR5(RcRjR5RdR;(
R`R�R&RIR)R*R�R�R+R,((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytrundoc\s

cCsSddl}|j|�}|jj|�|dkr@t}n|j|||�S(Ni�(tnewRIR�R�R2RiRh(R`RCR&RIRiR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytrundictes	cCs4ddl}|j|�}||_|j||�S(Ni�(RiRIR�Rh(R`RCR&RiR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytrun__test__ms	cCs|jj|�S(N(RdRB(R`R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRBsscCs|jj|j�dS(N(RdRD(R`R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRDvsN(
R;RdR2R{RgRhRjRkRBRD(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR<s					cCs2|t@|kr"td|��nt}|a|S(NsOnly reporting flags allowed(RR�t_unittest_reportflags(R6told((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRs
tDocTestCasecBskeZdd
d
d
d�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
e
Zd	�ZRS(icCsAtjj|�||_||_||_||_||_dS(N(tunittesttTestCaseR{t_dt_optionflagst_dt_checkert_dt_testt	_dt_setUpt_dt_tearDown(R`R�RtsetUpttearDownR((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR{�s				cCs,|j}|jdk	r(|j|�ndS(N(RsRtR2(R`R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRv�s	cCs9|j}|jdk	r(|j|�n|jj�dS(N(RsRuR2R5R8(R`R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRw�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|R9(RsRDR}R!RqRRlRRrRiRR;R3tfailureExceptiontformat_failureRU(R`R�RmRiRR\RR((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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(RsR�R2R�R&RfR�(R`terrR�R�tlname((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRy�s		
cCsI|j�td|jd|jdt�}|j|j�|j�dS(NRRR�(RvRRqRrRiR;RsRw(R`R\((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR �s

cCs
|jjS(N(RsR&(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR��scCs4|jjjd�}d|ddj|d �fS(NR�s%s (%s)i�(RsR&RfR�(R`R&((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR��scCsd|jjS(Ns	Doctest: (RsR&(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytshortDescription�sN(
R;RdR2R{RvRwRzRyR R�R�RUR}(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRn�s									c	Ks8|d
krt�}nt|�}|j|d|d|�}|d
krW|j}n|sot|d��n|j�tj�}x�|D]�}t	|j
�dkr�q�n|js|j}|ddkr�|d }n2t
jjd	�r|jd
�rd|d }n||_n|jt||��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.
    R5R�shas no testsii�s.pycs.pyoi�R�s	$py.classs%s.pyi�N(s.pycs.pyo(R2RRKRjR�R�R�Rot	TestSuiteR%R�R�R�RDR�RhR^taddTestRn(	RIR5R�ttest_finderR�R�tsuiteR�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s.%

		
tDocFileCasecBs)eZd�Zd�ZeZd�ZRS(cCsdj|jjjd��S(NR(R�(R�RsR&Rf(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�scCs
|jjS(N(RsR�(R`((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�!scCsd|jj|jj|fS(Ns2Failed doctest test for %s
  File "%s", line 0

%s(RsR&R�(R`R{((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyRy%s(R;RdR�R�RURy(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s		c	Ks�|dkri}n|r1|r1td��n|rUt|�}t||�}ntjj|�}t|�j�}|j	||||d�}t
||�S(Ns8Package may only be specified for module-relative paths.i(R2R�RKR�R�R�R]R^R_R�R�(	R�R`RaR5R�R�R&tdocR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pytDocFileTest*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.
    R`Ra(RoR~R1RkRKRR�(tpathstkwR�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR@s5
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�j
|�dS(Ni�s# Expected:s
s## Rsi(RR�R>R
R�R�RlRfRvtpopR�(ROR�tpieceRlR�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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(RKRRjR&R�RR�(RIR&R�R*R�ttestsrc((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR�s(
cCs t|�}t|||�dS(s4Debug a single doctest docstring, in argument `src`'N(Rtdebug_script(tsrctpmR5R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.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doctestdebugRqiisexecfile(%r)(RyttempfiletmktempR^R3tcloseR�texecfileRDRVtpost_mortemR;R�tremove(R�R�R5RytsrcfilenameR)((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR��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(RKRR�R�(RIR&R�R�((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyR �s(MR�t
__docformat__t__all__R/RDRSR<R�R�RMRoRJRyR�R*R!tfilterwarningsR,R;R#RRRRRRRRRR	R
RRFReRR9RKRQR[R\RrRvRzRwR�R
RRRRRt	ExceptionRRRR2RWRkRiRRRRRlRRpRnRR�R�RRRRR�R R�(((s5/sys/lib/python2.7/site-packages/nose/ext/dtcompat.pyt<module>4s�	H0
					,		$5<�4��	r	tA	
QB	F		 

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.