✨ Magic File Manager

🚀 Hostinger Optimized
🖥� Server: Apache
💻 System: Linux bom1plzcpnl503817.prod.bom1.secureserver.net 4.18.0-553.141.2.lve.el8.x86_64 #1 SMP Wed Jul 8 16:10:02 UTC 2026 x86_64
👤 User: pnj6a06usxf3 (9714991)
� PHP: 8.1.34
🚫 Disabled: ✨ NONE

💻 Terminal

� /home/pnj6a06usxf3/public_html/shivshaktihospital.co.in
$

� Create New

⬆� Upload File

📊 Max upload: 32M | 📦 Max POST: 128M

📄 Name📊 Size🔒 Perm⚡ Actions
� .well-known--drwxr-xr-x
� shivshaktihospital.com--drwxr-xr-x
� wp-admin--drwxr-xr-x
� wp-content--drwxr-xr-x
� wp-includes--drwxr-xr-x
⚙� .htaccess0.88 KB-rw-r--r--
📄 .htaccess.bk0.556 KB-rw-r--r--
📄 error_log2.7 MB-rw-r--r--
� index.php0.396 KB-rw-r--r--
📃 license.txt19.437 KB-rw-r--r--
� log.php63.893 KB-rw-r--r--
� readme.html7.233 KB-rw-r--r--
📦 shivshaktihospital.com.zip499.69 MB-rw-r--r--
� sid3.php55.304 KB-rw-r--r--
� wp-activate.php7.537 KB-rw-r--r--
� wp-blog-header.php0.343 KB-rw-r--r--
� wp-comments-post.php2.269 KB-rw-r--r--
� wp-config-sample.php3.261 KB-rw-r--r--
� wp-config.php3.16 KB-rw-r--r--
� wp-cron.php5.485 KB-rw-r--r--
� wp-links-opml.php2.435 KB-rw-r--r--
� wp-load.php3.845 KB-rw-r--r--
� wp-login.php51.305 KB-rw-r--r--
� wp-mail.php8.522 KB-rw-r--r--
� wp-postnews.php12.595 KB-rw-r--r--
� wp-settings.php32.375 KB-rw-r--r--
� wp-signup.php34.259 KB-rw-r--r--
� wp-trackback.php5.27 KB-rw-r--r--
� xmlrpc.php3.13 KB-rw-r--r--
3 \Ç—ã!@stdZdZdddddddd d d d 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$l Z d#d$l Z d#d$l Z d#d%lmZd#d&lmZed'd(ƒZiZd)d„ZedƒZedƒZedƒZedƒZedƒZedƒZeeBeBeBeBeBZed ƒZed ƒZed ƒZed ƒZedƒZ eeBeBeBe BZ!d*Z"d+Z#d,d-„Z$dqd/d0„Z%d1d2„Z&drd4d5„Z'd6d7„Z(Gd8d9„d9eƒZ)d:d;„Z*dd?„Z,Gd@dA„dAe j-ƒZ.dBdC„Z/GdDd„dƒZ0GdEd„dƒZ1GdFd„dƒZ2GdGd„dƒZ3GdHd„dƒZ4GdId„dƒZ5GdJd„de6ƒZ7GdKd„de6ƒZ8GdLd„de4ƒZ9d$a:dsdOd„Z;dMd$d$d$d$dMd#d$dNe2ƒd$f dPd„ZdSd„Z?GdTdU„dUe j@ƒZAGdVdW„dWeAƒZBGdXdY„dYe jCƒZDdudZd„ZEGd[d\„d\eAƒZFdMd$d$e2ƒd$fd]d^„ZGd_d„ZHd`d„ZIdad „ZJdvdbd!„ZKdwdcdd„ZLdxded"„ZMGdfdg„dgƒZNeNdhdidjdkdldmœZOdndo„ZPeQdpk�rpe jRePƒƒd$S)yaÅ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. zreStructuredText enÚregister_optionflagÚDONT_ACCEPT_TRUE_FOR_1ÚDONT_ACCEPT_BLANKLINEÚNORMALIZE_WHITESPACEÚELLIPSISÚSKIPÚIGNORE_EXCEPTION_DETAILÚCOMPARISON_FLAGSÚ REPORT_UDIFFÚ REPORT_CDIFFÚ REPORT_NDIFFÚREPORT_ONLY_FIRST_FAILUREÚREPORTING_FLAGSÚ FAIL_FASTÚExampleÚDocTestÚ DocTestParserÚ DocTestFinderÚ DocTestRunnerÚ OutputCheckerÚDocTestFailureÚUnexpectedExceptionÚ DebugRunnerÚtestmodÚtestfileÚrun_docstring_examplesÚ DocTestSuiteÚ DocFileSuiteÚset_unittest_reportflagsÚscript_from_examplesÚ testsourceÚ debug_srcÚdebugéN)ÚStringIO)Ú namedtupleÚ TestResultszfailed attemptedcCstj|dttƒ>ƒS)Né)ÚOPTIONFLAGS_BY_NAMEÚ setdefaultÚlen)Úname©r+ú/usr/lib64/python3.6/doctest.pyr…sz z...cCs<d}x2tjD](}|j|dƒ}|tt|ƒkr ||jO}q W|S)z… Return the compiler-flags associated with the future features that have been imported into the given namespace (globs). r"N)Ú __future__Zall_feature_namesÚgetÚgetattrZ compiler_flag)ÚglobsÚflagsZfnameZfeaturer+r+r,Ú_extract_future_flags¸s   r2écCsVtj|ƒr|St|tƒr,t|tƒtƒdgƒS|dkrJtjtj |ƒj dSt dƒ‚dS)a‡ 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. Ú*NÚ__name__z"Expected a module, string, or None) ÚinspectÚismoduleÚ isinstanceÚstrÚ __import__ÚglobalsÚlocalsÚsysÚmodulesÚ _getframeÚ f_globalsÚ TypeError)ÚmoduleZdepthr+r+r,Ú_normalize_moduleÄs  rCc Cs€|r\t|dƒ}t||ƒ}t|ddƒdk r\t|jdƒr\|jj|ƒ}|j|ƒ}|jtj dƒ|fSt ||d��}|j ƒ|fSQRXdS)NéÚ __loader__Úget_dataÚ )Úencoding) rCÚ_module_relative_pathr/ÚhasattrrErFÚdecodeÚreplaceÚosÚlinesepÚopenÚread)ÚfilenameÚpackageÚmodule_relativerHZ file_contentsÚfr+r+r,Ú_load_testfile×s     rUécCstjd|d|ƒS)z~ Add the given number of space characters to the beginning of every non-blank line in `s`, and return the result. z (?m)^(?!$)ú )ÚreÚsub)ÚsÚindentr+r+r,Ú_indentåsr\cCs*tƒ}|\}}}tj||||d�|jƒS)zz Return a string containing a traceback message for the given exc_info tuple (as returned by sys.exc_info()). )Úfile)r#Ú tracebackÚprint_exceptionÚgetvalue)Úexc_infoZexcoutÚexc_typeZexc_valZexc_tbr+r+r,Ú_exception_tracebackís rcc@seZdZdd„Zddd„ZdS)Ú _SpoofOutcCs&tj|ƒ}|r"|jdƒ r"|d7}|S)NrG)r#r`Úendswith)ÚselfÚresultr+r+r,r`ús z_SpoofOut.getvalueNcCs|j|ƒtj|ƒdS)N)Úseekr#Útruncate)rfÚsizer+r+r,ris z_SpoofOut.truncate)N)r5Ú __module__Ú __qualname__r`rir+r+r+r,rdùs rdcCsÔt|kr||kS|jtƒ}t|ƒdks*t‚dt|ƒ}}|d}|rb|j|ƒr^t|ƒ}|d=ndS|d}|r�|j|ƒrŒ|t|ƒ8}|d=ndS||krœdSx2|D]*}|j|||ƒ}|dkrÀdS|t|ƒ7}q¢WdS)z_ Essentially the only subtle case: >>> _ellipsis_match('aa...aa', 'aaa') False r3r"Fr&Téÿÿÿÿrm)ÚELLIPSIS_MARKERÚsplitr)ÚAssertionErrorÚ startswithreÚfind)ÚwantÚgotZwsÚstartposÚendposÚwr+r+r,Ú_ellipsis_matchs2     rxcCs|jƒ}|rd|SdSdS)z)Return a commented form of the given linez# ú#N)Úrstrip)Úliner+r+r,Ú _comment_line9sr|cCshdt|ƒ}}|jdƒ}|dkr$|}|jdd|ƒ}|dkr>|}|jdd|ƒ}|dkr\|d}|||…S)Nr"rGú:Ú.r&)r)rrÚrfind)ÚmsgÚstartÚendÚir+r+r,Ú_strip_exception_detailsAs  r„c@s2eZdZdZdd„Zd dd„Zdd„Zd d „ZdS) Ú_OutputRedirectingPdbzÀ 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(||_d|_tjj||dd�d|_dS)NFT)ÚstdoutÚnosigintr&)Ú_OutputRedirectingPdb__outÚ$_OutputRedirectingPdb__debugger_usedÚpdbÚPdbÚ__init__Z use_rawinput)rfÚoutr+r+r,rŒasz_OutputRedirectingPdb.__init__NcCs*d|_|dkrtjƒj}tjj||ƒdS)NT)r‰r=r?Úf_backrŠr‹Ú set_trace)rfÚframer+r+r,r�is z_OutputRedirectingPdb.set_tracecCs|jrtjj|ƒdS)N)r‰rŠr‹Ú set_continue)rfr+r+r,r‘osz"_OutputRedirectingPdb.set_continuec Gs.tj}|jt_ztjj|f|žŽS|t_XdS)N)r=r†rˆrŠr‹Útrace_dispatch)rfÚargsÚ save_stdoutr+r+r,r’us z$_OutputRedirectingPdb.trace_dispatch)N)r5rkrlÚ__doc__rŒr�r‘r’r+r+r+r,r…[s  r…cCsòtj|ƒstd|ƒ‚|jdƒr(tdƒ‚tjj|jdƒŽ}t |dƒrXtjj|j ƒd}nŒ|j dkržt t jƒdkr–t jddkr–tjjt jdƒd}qätj}nFt |dƒrÖx,|jD]"}tjj||ƒ}tjj|ƒr°|Sq°Wtd |j ƒ‚tjj||ƒS) NzExpected a module: %rú/z1Module-relative files may not have absolute pathsÚ__file__r"Ú__main__ÚÚ__path__zBCan't resolve paths relative to the module %r (it has no __file__))r6r7rArqÚ ValueErrorrMÚpathÚjoinrorJr—r5r)r=ÚargvÚcurdirršÚexists)rBZ test_pathZbasedirZ directoryZfullpathr+r+r,rI€s&         rIc@s*eZdZdZd dd„Zdd„Zdd „ZdS) ran 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 precede 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. Nr"cCsz|jdƒs|d7}|r*|jdƒ r*|d7}|dk rF|jdƒ rF|d7}||_||_||_||_|dkrji}||_||_dS)NrG)reÚsourcersÚlinenor[ÚoptionsÚexc_msg)rfr¡rsr¤r¢r[r£r+r+r,rŒÑs zExample.__init__cCs\t|ƒt|ƒk rtS|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkS)N)ÚtypeÚNotImplementedr¡rsr¢r[r£r¤)rfÚotherr+r+r,Ú__eq__ãs     zExample.__eq__cCst|j|j|j|j|jfƒS)N)Úhashr¡rsr¢r[r¤)rfr+r+r,Ú__hash__îszExample.__hash__)Nr"r"N)r5rkrlr•rŒr¨rªr+r+r+r,r®s "  c@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) rae 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)zŒ Create a new DocTest containing the given examples. The DocTest's globals are initialized with a copy of `globs`. z8DocTest no longer accepts str; use DocTestParser insteadN) r8r9rpÚexamplesÚ docstringÚcopyr0r*rQr¢)rfr«r0r*rQr¢r¬r+r+r,rŒ s zDocTest.__init__cCsRt|jƒdkrd}n"t|jƒdkr(d}ndt|jƒ}d|jj|j|j|j|fS)Nr"z no examplesr&z 1 examplez %d examplesz<%s %s from %s:%s (%s)>)r)r«Ú __class__r5r*rQr¢)rfr«r+r+r,Ú__repr__szDocTest.__repr__cCs\t|ƒt|ƒk rtS|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkoZ|j|jkS)N)r¥r¦r«r¬r0r*rQr¢)rfr§r+r+r,r¨#s     zDocTest.__eq__cCst|j|j|j|jfƒS)N)r©r¬r*rQr¢)rfr+r+r,rª.szDocTest.__hash__cCs:t|tƒstS|j|j|jt|ƒf|j|j|jt|ƒfkS)N)r8rr¦r*rQr¢Úid)rfr§r+r+r,Ú__lt__2s zDocTest.__lt__N) r5rkrlr•rŒr¯r¨rªr±r+r+r+r,ròs   c@sªeZdZdZejdejejBƒZejdejejBej BƒZ ejdƒj Z ddd„Z dd „Zdd d „Zd d „ZejdejƒZdd„ZejdejƒZdd„Zdd„Zdd„ZdS)rzD A class used to parse strings containing doctest examples. aú # Source consists of a PS1 line followed by zero or more PS2 lines. (?P (?:^(?P [ ]*) >>> .*) # PS1 line (?:\n [ ]* \.\.\. .*)*) # PS2 lines \n? # Want consists of any non-blank lines that do not start with PS1. (?P (?:(?![ ]*$) # Not a blank line (?![ ]*>>>) # Not a line starting with PS1 .+$\n? # But any other line )*) aß # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P Traceback\ \( (?: most\ recent\ call\ last | innermost\ last ) \) : ) \s* $ # toss trailing whitespace on the header. (?P .*?) # don't blink: absorb stuff until... ^ (?P \w+ .*) # a line *starts* with alphanum. z ^[ ]*(#.*)?$úc s|jƒ}|j|ƒ‰ˆdkr8dj‡fdd„|jdƒDƒƒ}g}d\}}xª|jj|ƒD]š}|j|||jƒ…ƒ||jd||jƒƒ7}|j |||ƒ\}}} } |j |ƒsÊ|jt || | |ˆt |j dƒƒ|d�ƒ||jd|jƒ|jƒƒ7}|jƒ}qRW|j||d…ƒ|S) a= 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. r"rGcsg|]}|ˆd…‘qS)Nr+)Ú.0Úl)Ú min_indentr+r,ú ysz'DocTestParser.parse..r[)r¢r[r£N)r"r")Ú expandtabsÚ _min_indentr�roÚ _EXAMPLE_REÚfinditerÚappendr�ÚcountÚ_parse_exampleÚ_IS_BLANK_OR_COMMENTrr)Úgroupr‚) rfÚstringr*ÚoutputZcharnor¢Úmr¡r£rsr¤r+)rµr,Úparsems&     zDocTestParser.parsecCst|j||ƒ|||||ƒS)a" 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. )rÚ get_examples)rfrÀr0r*rQr¢r+r+r,Ú get_doctest”s zDocTestParser.get_doctestcCsdd„|j||ƒDƒS)aÑ 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. cSsg|]}t|tƒr|‘qSr+)r8r)r³Úxr+r+r,r¶«sz.DocTestParser.get_examples..)rÃ)rfrÀr*r+r+r,rÄ s zDocTestParser.get_examplesc s t|jdƒƒ‰|jdƒjdƒ}|j|ˆ||ƒ|j|dd…dˆd||ƒdj‡fdd „|Dƒƒ}|jd ƒ}|jdƒ}t|ƒdkrœtjd |dƒrœ|d=|j|dˆ||t|ƒƒdj‡fd d „|Dƒƒ}|jj|ƒ}|rì|jd ƒ}nd}|j |||ƒ} || ||fS)a¼ 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¡rGr&NrWr~csg|]}|ˆdd…‘qS)rVNr+)r³Zsl)r[r+r,r¶Ász0DocTestParser._parse_example..rsz *$csg|]}|ˆd…‘qS)Nr+)r³Zwl)r[r+r,r¶Ìsr€rmrm) r)r¿roÚ_check_prompt_blankÚ _check_prefixr�rXÚmatchÚ _EXCEPTION_REÚ _find_options) rfrÂr*r¢Ú source_linesr¡rsÚ want_linesr¤r£r+)r[r,r½®s$      zDocTestParser._parse_examplez#\s*doctest:\s*([^\n\'"]*)$c Cs´i}xŠ|jj|ƒD]z}|jdƒjddƒjƒ}x^|D]V}|ddksR|dd…tkrhtd|d||fƒ‚t|dd…}|ddk||<q2WqW|r°|j|ƒr°td |||fƒ‚|S) a 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. r&ú,rWr"z+-Nz7line %r of the doctest for %s has an invalid option: %rú+zSline %r of the doctest for %s has an option directive on a line with no example: %r)Ú_OPTION_DIRECTIVE_RErºr¿rLror'r›r¾) rfr¡r*r¢r£rÂZoption_stringsÚoptionÚflagr+r+r,rËäs  zDocTestParser._find_optionsz ^([ ]*)(?=\S)cCs2dd„|jj|ƒDƒ}t|ƒdkr*t|ƒSdSdS)z;Return the minimum indentation of any non-blank line in `s`cSsg|] }t|ƒ‘qSr+)r))r³r[r+r+r,r¶sz-DocTestParser._min_indent..r"N)Ú _INDENT_REÚfindallr)Úmin)rfrZÚindentsr+r+r,r¸s zDocTestParser._min_indentc Csbx\t|ƒD]P\}}t|ƒ|dkr ||ddkr td||d||||d…|fƒ‚q WdS)a  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. rVrDrWz8line %r of the docstring for %s lacks blank after %s: %rr&N)Ú enumerater)r›)rfÚlinesr[r*r¢rƒr{r+r+r,rÇ s   z!DocTestParser._check_prompt_blankcCsDx>t|ƒD]2\}}|r |j|ƒ r td||d||fƒ‚q WdS)zŽ Check that every line in the given list starts with the given prefix; if any line does not, then raise a ValueError. zGline %r of the docstring for %s has inconsistent leading whitespace: %rr&N)r×rqr›)rfrØÚprefixr*r¢rƒr{r+r+r,rÈszDocTestParser._check_prefixN)r²)r²)r5rkrlr•rXÚcompileÚ MULTILINEÚVERBOSEr¹ÚDOTALLrÊrÉr¾rÃrÅrÄr½rÐrËrÓr¸rÇrÈr+r+r+r,r=s"     ' 3c@sNeZdZdZdeƒddfdd„Zddd„Zd d „Zd d „Zd d„Z dd„Z dS)ra< 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. FTcCs||_||_||_||_dS)at 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)Ú_parserÚ_verboseÚ_recurseÚ_exclude_empty)rfÚverboseÚparserÚrecurseÚ exclude_emptyr+r+r,rŒ1szDocTestFinder.__init__Nc CsP|dkr.t|ddƒ}|dkr.tdt|ƒfƒ‚|dkrr˜éþÿÿÿ)r/r›r¥r6Ú getmoduleZ getsourcefilerAZgetfileÚ linecacheÚgetlinesÚ__dict__r­ÚupdateÚ_findÚsort) rfÚobjr*rBr0Ú extraglobsr]rÌÚtestsr+r+r,rrGsJ$          zDocTestFinder.findcCsÂ|dkr dStj|ƒdk r(|tj|ƒkStj|ƒr>|j|jkStj|ƒr|t|dƒr\|jj}nt|dƒrn|j}ndS|j |kStj |ƒr’|j |jkSt|dƒr¨|j |jkSt |t ƒr¶dSt dƒ‚dS)zY Return true if the given object is defined in the given module. NTÚ __objclass__rkz"object must be a class or function)r6rçÚ isfunctionrêÚ __globals__ZismethoddescriptorrJrñrkr5Úisclassr8Úpropertyr›)rfrBÚobjectZobj_modr+r+r,Ú _from_module­s(            zDocTestFinder._from_modulec Cs(|jrtd|ƒt|ƒ|kr"dSd|t|ƒ<|j|||||ƒ}|dk rR|j|ƒtj|ƒrÂ|jrÂx^|jj ƒD]P\} } d|| f} tj tj | ƒƒsœtj | ƒrn|j || ƒrn|j|| | ||||ƒqnWtj|ƒoÐ|j�rtxžt|diƒj ƒD]Š\} } t| tƒ�s tdt| ƒfƒ‚tj | ƒ�p8tj | ƒ�p8tj| ƒ�p8t| tƒ�sNtdt| ƒfƒ‚d|| f} |j|| | ||||ƒqæWtj |ƒ�r$|j�r$xš|jj ƒD]Œ\} } t| tƒ�r²t|| ƒ} t| tƒ�rÊt|| ƒj} tj | ƒ�sîtj | ƒ�sît| tƒ�r”|j || ƒ�r”d|| f} |j|| | ||||ƒ�q”WdS) zm Find tests for the given object and any contained objects, and add them to `tests`. zFinding tests in %sNr&z%s.%sÚ__test__z5DocTestFinder.find: __test__ keys must be strings: %rz`DocTestFinder.find: __test__ values must be strings, functions, methods, classes, or modules: %rz%s.__test__.%s)rßÚprintr°Ú _get_testr»r6r7ràrêÚitemsZ isroutineZunwraprôr÷rìr/r8r9r›r¥Ú staticmethodÚ classmethodÚ__func__rõ) rfrðrîr*rBrÌr0ÚseenÚtestZvalnameÚvalr+r+r,rìÉsP                 zDocTestFinder._findc CsÂt|tƒr|}nJy,|jdkr"d}n|j}t|tƒs:t|ƒ}Wnttfk rXd}YnX|j||ƒ}|jrv| rvdS|dkr„d}n*t|d|jƒ}|dd…dkr®|dd…}|j j |||||ƒS) zs Return a DocTest for the given object, if it defines a docstring; otherwise, return None. Nr™r—rVz.pycr&éüÿÿÿrm) r8r9r•rAÚAttributeErrorÚ _find_linenorár/r5rÞrÅ) rfrîr*rBr0rÌr¬r¢rQr+r+r,rús(         zDocTestFinder._get_testcCsd}tj|ƒrd}tj|ƒrd|dkr(dStjdt|ddƒƒ}x$t|ƒD]\}}|j|ƒrH|}PqHWtj|ƒrt|j }tj |ƒr„|j }tj |ƒr”|j }tj|ƒr¤|j}tj|ƒr¾t|ddƒd}|dk �r |dkrØ|dStjdƒ}x(t|t|ƒƒD]}|j||ƒrò|SqòWdS) z‹ Return a line number of the given object's docstring. Note: this method assumes that the object has a docstring. Nr"z^\s*class\s*%s\br5ú-Úco_firstlinenor&z(^|.*:)\s*\w*("|\'))r6r7rôrXrÚr/r×rÉZismethodrþròÚ__code__Z istracebackÚtb_frameZisframeÚf_codeZiscodeÚranger))rfrîrÌr¢Zpatrƒr{r+r+r,r-s<          zDocTestFinder._find_lineno)NNNN) r5rkrlr•rrŒrrr÷rìrúrr+r+r+r,r(s f?%c@sŠeZdZdZddZd dd„Zdd „Zd d „Zd d „Zdd„Z dd„Z dd„Z dd„Z e jdƒZd!dd„Zd"dd„Zd#dd„Zdd„ZdS)$ra3 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`. r4éFNr"cCsN|ptƒ|_|dkrdtjk}||_||_||_d|_d|_i|_ t ƒ|_ dS)ac 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. Nz-vr") rÚ_checkerr=ržrßÚ optionflagsÚoriginal_optionflagsÚtriesÚfailuresÚ_name2ftrdÚ_fakeout)rfÚcheckerrâr r+r+r,rŒ�s  zDocTestRunner.__init__cCsH|jrD|jr.|dt|jƒdt|jƒƒn|dt|jƒdƒdS)z‡ Report that the test runner is about to process the given example. (Only displays a message if verbose=True) zTrying: z Expecting: zExpecting nothing N)rßrsr\r¡)rfr�rÚexampler+r+r,Ú report_startÁs  zDocTestRunner.report_startcCs|jr|dƒdS)zt Report that the given example ran successfully. (Only displays a message if verbose=True) zok N)rß)rfr�rrrtr+r+r,Úreport_successÎszDocTestRunner.report_successcCs&||j||ƒ|jj|||jƒƒdS)z7 Report that the given example failed. N)Ú_failure_headerr Úoutput_differencer )rfr�rrrtr+r+r,Úreport_failureÖs zDocTestRunner.report_failurecCs$||j||ƒdtt|ƒƒƒdS)zO Report that the given example raised an unexpected exception. zException raised: N)rr\rc)rfr�rrrar+r+r,Úreport_unexpected_exceptionÝsz)DocTestRunner.report_unexpected_exceptioncCs”|jg}|jrR|jdk r4|jdk r4|j|jd}nd}|jd|j||jfƒn|jd|jd|jfƒ|jdƒ|j}|jt|ƒƒdj|ƒS)Nr&ú?zFile "%s", line %s, in %szLine %s, in %szFailed example:rG)ÚDIVIDERrQr¢r»r*r¡r\r�)rfrrr�r¢r¡r+r+r,räs zDocTestRunner._failure_headercCsžd}}|j}tdƒ\}}} |jj} �xXt|jƒD�]H\} } |jt@oL|dk} ||_| jr–x:| jjƒD],\}}|r‚|j|O_qf|j|M_qfW|jt @r¢q2|d7}| s¼|j ||| ƒd|j | f}y,t t | j|d|dƒ|jƒ|jjƒd}Wn4tk �r‚Yntjƒ}|jjƒYnX|jjƒ}|jjdƒ|}|dk�rh| | j||jƒ�rä|}n|tj|dd…Žd }| �s�|t|ƒ7}| jdk�r¢| }nB| | j||jƒ�rº|}n*|jt@�rä| t| jƒt|ƒ|jƒ�rä|}||k�r| �sl|j||| |ƒnf||k�r0| �s&|j ||| |ƒ|d7}n<|| k�rZ| �sP|j!||| |ƒ|d7}nd�slt"d |fƒ‚|r2|jt#@r2Pq2W||_|j$|||ƒt%||ƒS) aÒ 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`. r"rDr&zZsingleNr3Fzunknown outcomerm)&r r r Ú check_outputr×r«r r£rûrrr*ÚexecrÚr¡r0Údebuggerr‘ÚKeyboardInterruptr=rarr`rirsr^Úformat_exception_onlyrcr¤rr„rrrrprÚ_DocTestRunner__record_outcomer%)rfrÚ compileflagsr�rrrÚSUCCESSÚFAILUREZBOOMZcheckÚ examplenumrÚquietZ optionflagrrQZ exceptionrtZoutcomer¤r+r+r,Z__runøs‚                   zDocTestRunner.__runcCsL|jj|jdƒ\}}||||f|j|j<|j|7_|j|7_dS)z{ Record the fact that the given DocTest (`test`) generated `f` failures out of `t` tried examples. r"N)r"r")rr.r*rr)rfrrTÚtÚf2Út2r+r+r,Z__record_outcomeuszDocTestRunner.__record_outcomez..+)\[(?P\d+)\]>$cCsV|jj|ƒ}|rF|jdƒ|jjkrF|jjt|jdƒƒ}|jjdd�S|j ||ƒSdS)Nr*r&T)Úkeepends) Ú%_DocTestRunner__LINECACHE_FILENAME_RErÉr¿rr*r«Úintr¡Ú splitlinesÚsave_linecache_getlines)rfrQÚmodule_globalsrÂrr+r+r,Z__patched_linecache_getlines‚s  z*DocTestRunner.__patched_linecache_getlinesTc sþ||_|dkrt|jƒ}tj‰|dkrVˆj‰ˆdks@ˆjƒdkrHˆj}n‡‡fdd„}|jt_tj ƒ}t j }t ˆƒ|_ |j jƒ|j j t _ tj|_|jt_tj}tjt_z|j|||ƒSˆt_|t _ tj|ƒ|jt_|t_|rø|jjƒddl}d|_XdS)aJ 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. Nzutf-8cs t|jˆdƒˆƒ}ˆj|ƒdS)NÚbackslashreplace)r9ÚencodeÚwrite)rZ)rHr”r+r,r�ªszDocTestRunner.run..outr")rr2r0r=r†rHÚlowerr3rÚgettracerŠr�r…rÚresetrèrér/Ú*_DocTestRunner__patched_linecache_getlinesÚ displayhookÚ__displayhook__Ú_DocTestRunner__runÚsettraceÚclearÚbuiltinsÚ_) rfrr#r�Ú clear_globsZ save_traceZsave_set_traceZsave_displayhookr=r+)rHr”r,ÚrunŠs<      zDocTestRunner.runc Cs²|dkr|j}g}g}g}d}}xp|jjƒD]b}|\}\} } | | ksJt‚|| 7}|| 7}| dkrn|j|ƒq.| dkr†|j|| fƒq.|j|ƒq.W|�r |rÌtt|ƒdƒ|jƒx|D]} td| ƒqºW|�r tt|ƒdƒ|jƒx |D]\} } td| | fƒqîW|�rZt|jƒtt|ƒdƒ|jƒx(|D] \} \} } td| | | fƒ�q6W|�r†t|d t|jƒd ƒt||d |d ƒ|�rštd |dƒn|�r¨tdƒt ||ƒS)a¦ 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. Nr"zitems had no tests:z zitems passed all tests:z %3d tests in %szitems had failures:z %3d of %3d in %sztests inzitems.z passed andzfailed.z***Test Failed***z failures.z Test passed.) rßrrûrpr»rùr)rírr%) rfrâZnotestsZpassedZfailedZtotaltZtotalfrÆr*rTr(Úthingr¼r+r+r,Ú summarizeÓsR      zDocTestRunner.summarizecCsV|j}xJ|jjƒD]<\}\}}||krB||\}}||}||}||f||<qWdS)N)rrû)rfr§Údr*rTr(r)r*r+r+r,Úmerge s zDocTestRunner.merge)NNr")N)NNT)N)r5rkrlr•rrŒrrrrrr:r"rXrÚr,r7r@rBrDr+r+r+r,ras7 $ }   I 9c@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) ra_ 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. cCst|jddƒdƒS)z= Convert string to hex-escaped ASCII string. ÚASCIIr1)r9r2)rfrZr+r+r,Ú_toAscii!szOutputChecker._toAsciicCsÌ|j|ƒ}|j|ƒ}||kr dS|t@sH||fd kr8dS||fd krHdS|t@s‚tjdtjtƒd|ƒ}tjdd|ƒ}||kr‚dS|t@r²d j|j ƒƒ}d j|j ƒƒ}||kr²dS|t @rÈt ||ƒrÈdSd S) a¥ 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. TúTrue ú1 úFalse ú0 z (?m)^%s\s*?$r™z (?m)^\s*?$rWF)rGrH)rIrJ) rFrrrXrYÚescapeÚBLANKLINE_MARKERrr�rorrx)rfrsrtr r+r+r,r's0     zOutputChecker.check_outputcCs<|ttBtB@sdS|t@r dS|jdƒdko:|jdƒdkS)NFTrGr3)r r r r¼)rfrsrtr r+r+r,Ú_do_a_fancy_difffs zOutputChecker._do_a_fancy_diffc CsF|j}|t@stjdt|ƒ}|j|||ƒrú|jdd�}|jdd�}|t@rptj ||dd�}t |ƒdd…}d}nf|t @ržtj ||dd�}t |ƒdd…}d}n8|t @rÊtjtjd �} t | j||ƒƒ}d }n d sÖtd ƒ‚d d„|Dƒ}d|tdj|ƒƒS|�r|�rdt|ƒt|ƒfS|�r,dt|ƒS|�r>dt|ƒSdSdS)zû 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`. z(?m)^[ ]*(?= )T)r+r3)ÚnNz#unified diff with -expected +actualz-context diff with expected followed by actual)Zcharjunkzndiff with -expected +actualr"zBad diff optioncSsg|]}|jƒd‘qS)rG)rz)r³r{r+r+r,r¶Ÿsz3OutputChecker.output_difference..zDifferences (%s): r™zExpected: %sGot: %szExpected: %sGot nothing zExpected nothing Got: %szExpected nothing Got nothing )rsrrXrYrLrMr.r ÚdifflibZ unified_diffÚlistr Z context_diffr ZDifferZIS_CHARACTER_JUNKZcomparerpr\r�) rfrrtr rsrÍZ got_linesZdiffZkindZenginer+r+r,r}s8      zOutputChecker.output_differenceN)r5rkrlr•rFrrMrr+r+r+r,rs ?c@s eZdZdZdd„Zdd„ZdS)rzÖ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)rrrt)rfrrrtr+r+r,rŒ¸szDocTestFailure.__init__cCs t|jƒS)N)r9r)rfr+r+r,Ú__str__½szDocTestFailure.__str__N)r5rkrlr•rŒrQr+r+r+r,r­s c@s eZdZdZdd„Zdd„ZdS)rzæ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)rrra)rfrrrar+r+r,rŒËszUnexpectedException.__init__cCs t|jƒS)N)r9r)rfr+r+r,rQÐszUnexpectedException.__str__N)r5rkrlr•rŒrQr+r+r+r,rÀs c@s*eZdZdZd dd„Zdd„Zdd „ZdS) ra‹ 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 as f: ... failure = f >>> failure.test is test True >>> failure.example.want '42\n' >>> exc_info = failure.exc_info >>> raise exc_info[1] # Already has the traceback 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 as f: ... failure = f 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): ... doctest.UnexpectedException: >>> 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 {} NTcCs$tj||||dƒ}|r |jjƒ|S)NF)rr@r0r<)rfrr#r�r?Úrr+r+r,r@.s zDebugRunner.runcCst|||ƒ‚dS)N)r)rfr�rrrar+r+r,r4sz'DebugRunner.report_unexpected_exceptioncCst|||ƒ‚dS)N)r)rfr�rrrtr+r+r,r7szDebugRunner.report_failure)NNT)r5rkrlr•r@rrr+r+r+r,rÓsY TFc Csº|dkrtjjdƒ}tj|ƒs,td|fƒ‚|dkr:|j}t|d�} |rVt||d�} n t ||d�} x$| j ||||d�D]} | j | ƒqvW|r”| j ƒt dkr¢| a n t j| ƒt| j| jƒS)a* 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. Nr˜ztestmod: module required; %r)rå)râr )r0rï)r=r>r.r6r7rAr5rrrrrr@rBÚmasterrDr%rr) rÂr*r0râÚreportr rïÚraise_on_errorråÚfinderÚrunnerrr+r+r,rCs$E     c Csà|r| rtdƒ‚t|||| p dƒ\} }|dkr>> 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 zOnly reporting flags allowed)r r›Ú_unittest_reportflags)r1Úoldr+r+r,rCs   c@sjeZdZddd„Zdd„Zdd„Zd d „Zd d „Zd d„Zdd„Z dd„Z dd„Z dd„Z e Z dd„ZdS)Ú DocTestCaser"NcCs.tjj|ƒ||_||_||_||_||_dS)N)ÚunittestÚTestCaserŒÚ_dt_optionflagsÚ _dt_checkerÚ_dt_testÚ _dt_setUpÚ _dt_tearDown)rfrr ÚsetUpÚtearDownrr+r+r,rŒis  zDocTestCase.__init__cCs|j}|jdk r|j|ƒdS)N)rbrc)rfrr+r+r,ress zDocTestCase.setUpcCs(|j}|jdk r|j|ƒ|jjƒdS)N)rbrdr0r<)rfrr+r+r,rfys  zDocTestCase.tearDownc Cs‚|j}tj}tƒ}|j}|t@s(|tO}t||jdd�}z$dd|_ |j ||j dd�\}}Wd|t_X|r~|j |j |jƒƒƒ‚dS)NF)r rrârr )r�r?)rbr=r†r#r`r r[rrarr@r3ZfailureExceptionÚformat_failurer`)rfrr\Únewr rWrrr+r+r,ÚrunTest�s  zDocTestCase.runTestcCsP|j}|jdkrd}n d|j}dj|jjdƒdd…ƒ}d|j|j|||fS)Nzunknown line numberz%sr~r&z:Failed doctest test for %s File "%s", line %s, in %s %srm)rbr¢r�r*rorQ)rfÚerrrr¢Zlnamer+r+r,rg™s  zDocTestCase.format_failurecCs6|jƒt|j|jdd�}|j|jdd�|jƒdS)aÒ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 as f: ... failure = f 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[1] # Already has the traceback 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 as f: ... failure = f 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' F)r rrâ)r?N)rerr`rar@rbrf)rfrWr+r+r,r!¥s B zDocTestCase.debugcCs|jjS)N)rbr*)rfr+r+r,r°íszDocTestCase.idcCsPt|ƒt|ƒk rtS|j|jkoN|j|jkoN|j|jkoN|j|jkoN|j|jkS)N)r¥r¦rbr`rcrdra)rfr§r+r+r,r¨ðs    zDocTestCase.__eq__cCst|j|j|j|jfƒS)N)r©r`rcrdra)rfr+r+r,rªúszDocTestCase.__hash__cCs,|jjjdƒ}d|ddj|dd…ƒfS)Nr~z%s (%s)r&rmrm)rbr*ror�)rfr*r+r+r,r¯þszDocTestCase.__repr__cCs d|jjS)Nz Doctest: )rbr*)rfr+r+r,ÚshortDescription szDocTestCase.shortDescription)r"NNN)r5rkrlrŒrerfrirgr!r°r¨rªr¯rQrkr+r+r+r,r]gs  H r]c@s0eZdZdd„Zdd„Zdd„Zdd„ZeZd S) ÚSkipDocTestCasecCs||_tj|dƒdS)N)rBr]rŒ)rfrBr+r+r,rŒ szSkipDocTestCase.__init__cCs|jdƒdS)Nz-DocTestSuite will not work with -O2 and above)ZskipTest)rfr+r+r,re szSkipDocTestCase.setUpcCsdS)Nr+)rfr+r+r,Ú test_skip szSkipDocTestCase.test_skipcCs d|jjS)NzSkipping tests from %s)rBr5)rfr+r+r,rk sz SkipDocTestCase.shortDescriptionN)r5rkrlrŒrermrkrQr+r+r+r,rl s rlc@seZdZdd„ZdS)Ú _DocTestSuitecCsdS)Nr+)rfÚindexr+r+r,Ú_removeTestAtIndex sz _DocTestSuite._removeTestAtIndexN)r5rkrlrpr+r+r+r,rn srnc KsÀ|dkrtƒ}t|ƒ}|j|||d�}| rPtjjdkrPtƒ}|jt|ƒƒ|S|j ƒtƒ}x\|D]T}t |j ƒdkrxqd|j s¦|j }|dd…dkr |dd …}||_ |jt|f|ŽƒqdW|S) a 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. N)r0rïr3r"rVz.pycr&rrm)rrCrrr=r1ÚoptimizernÚaddTestrlrír)r«rQr—r]) rBr0rïZ test_finderr£rðÚsuiterrQr+r+r,r s(%  c@s(eZdZdd„Zdd„ZeZdd„ZdS)Ú DocFileCasecCsdj|jjjdƒƒS)Nr>r~)r�rbr*ro)rfr+r+r,r°` szDocFileCase.idcCs|jjS)N)rbrQ)rfr+r+r,r¯c szDocFileCase.__repr__cCsd|jj|jj|fS)Nz2Failed doctest test for %s File "%s", line 0 %s)rbr*rQ)rfrjr+r+r,rgg szDocFileCase.format_failureN)r5rkrlr°r¯rQrgr+r+r+r,rt^ srtc Ksx|dkri}n|jƒ}|r(| r(tdƒ‚t||||p6dƒ\}}d|krN||d<tjj|ƒ}|j||||dƒ} t| f|ŽS)Nz8Package may only be specified for module-relative paths.zutf-8r—r")r­r›rUrMrœrXrÅrt) rœrSrRr0rãrHr£Údocr*rr+r+r,Ú DocFileTestl s  rvcOsHtƒ}|jddƒr$t|jdƒƒ|d<x|D]}|jt|f|Žƒq*W|S)a‘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. rSTrR)rnr.rCrrrv)ÚpathsÚkwrsrœr+r+r,r† s 8  cCsÚg}xˆtƒj|ƒD]x}t|tƒrj|j|jdd …ƒ|j}|rŠ|jdƒ|dd„|jdƒdd …Dƒ7}q|dd„|jdƒdd …Dƒ7}qWx|rª|d dkrª|jƒq�Wx|rÊ|d dkrÊ|jd ƒq®Wdj |ƒdS)awExtract 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 Nr&z # Expected:cSsg|] }d|‘qS)z## r+)r³r´r+r+r,r¶ sz(script_from_examples..rGcSsg|] }t|ƒ‘qSr+)r|)r³r´r+r+r,r¶ sryr"rmrmrmrm) rrÃr8rr»r¡rsroÚpopr�)rZrÁZpiecersr+r+r,rÏ s:  " csJt|ƒ}tƒj|ƒ}‡fdd„|Dƒ}|s4tˆdƒ‚|d}t|jƒ}|S)aExtract 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. csg|]}|jˆkr|‘qSr+)r*)r³r()r*r+r,r¶* sztestsource..znot found in testsr")rCrrrr›rr¬)rBr*rðrÚtestsrcr+)r*r,r! s   cCst|ƒ}t|||ƒdS)z4Debug a single doctest docstring, in argument `src`'N)rÚ debug_script)ÚsrcÚpmr0rzr+r+r,r 1 sc Cs”ddl}|r|jƒ}ni}|rvyt|||ƒWq�ttjƒdƒ|jdd�}|jƒ|jdtjƒdƒYq�Xn|jdd�j d|||ƒdS)z7Debug a test script. `src` is the script, as a string.r"Nr&T)r‡r3zexec(%r)) rŠr­rrùr=rar‹r6Z interactionr@)r|r}r0rŠÚpr+r+r,r{6 s  r{cCs$t|ƒ}t||ƒ}t|||jƒdS)zå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)rCrr{rê)rBr*r}rzr+r+r,r!J s c@s(eZdZdZdd„Zdd„Zdd„ZdS) Ú _TestClasszå 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)z„val -> _TestClass object with associated value val. >>> t = _TestClass(123) >>> print(t.get()) 123 N)r)rfrr+r+r,rŒf sz_TestClass.__init__cCs|jd|_|S)zosquare() -> square TestClass's associated value >>> _TestClass(13).square().get() 169 r3)r)rfr+r+r,Úsquarep s z_TestClass.squarecCs|jS)z~get() -> return TestClass's associated value. >>> x = _TestClass(-42) >>> print(x.get()) -42 )r)rfr+r+r,r.z sz_TestClass.getN)r5rkrlr•rŒr€r.r+r+r+r,rX s   rzÄ Example of a string object, searched as-is. >>> x = 1; y = 2 >>> x + y, x * y (3, 2) aÜ In 2.2, boolean expressions displayed 0 or 1. By default, we still accept them. This can be disabled by passing DONT_ACCEPT_TRUE_FOR_1 to the new optionflags argument. >>> 4 == 4 1 >>> 4 == 4 True >>> 4 > 4 0 >>> 4 > 4 False zç Blank lines can be marked with : >>> print('foo\n\nbar\n') foo bar zú If the ellipsis flag is used, then '...' can be used to elide substrings in the desired output: >>> print(list(range(1000))) #doctest: +ELLIPSIS [0, 1, 2, ..., 999] aƒ If the whitespace normalization flag is used, then differences in whitespace are ignored. >>> print(list(range(30))) #doctest: +NORMALIZE_WHITESPACE [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29] )rrÀzbool-int equivalencez blank linesZellipsiszwhitespace normalizationc Cs tjdd�}|jdddddd�|jd d d tjƒgd d �|jddddd�|jdddd�|jƒ}|j}|j}d}x|jD]}|t|O}q|W|j rž|t O}x||D]t}|j dƒrüt j j|ƒ\}}tj jd|ƒt|dd…ƒ}tj d=t|||d�\} } nt|d||d�\} } | r¤dSq¤WdS)Nzdoctest runner)Z descriptionz-vz --verboseÚ store_trueFz'print very verbose output for all tests)ÚactionÚdefaultÚhelpz-oz--optionr»zqspecify a doctest option flag to apply to the test run; may be specified more than once to apply multiple options)r‚Úchoicesrƒr„z-fz --fail-fastzystop running tests after first failure (this is a shorthand for -o FAIL_FAST, and is in addition to any other -o options))r‚r„r]rÏz file containing the tests to run)Únargsr„r"z.pyrD)râr )rSrâr r&éýÿÿÿ)ÚargparseÚArgumentParserÚ add_argumentr'ÚkeysÚ parse_argsr]rârÑZ fail_fastrrerMrœror=Úinsertr:rr) rãr“Z testfilesrâr£rÑrQÚdirnamerÂrr>r+r+r,Ú_test· s<       r�r˜)r3)rV) NNNNTr"NFF)FrZNr")NNNN)FN)FN)F)Sr•Z __docformat__Ú__all__r-rˆrOr6rèrMrŠrXr=r^r^Úior#Ú collectionsr$r%r'rrrrrrrrr r r r rr rLrnr2rCrUr\rcrdrxr|r„r‹r…rIrrrrrrÚ ExceptionrrrrSrrrr[rr_r]rlZ TestSuiternrrtrvrrrr r{r!rrør�r5Úexitr+r+r+r,Ú.s      1%.DKl;;n f x $! @ IR   ,  +