diff options
Diffstat (limited to 'Doc/lib/libdoctest.tex')
-rw-r--r-- | Doc/lib/libdoctest.tex | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex index 957ecf4..5e28c2a 100644 --- a/Doc/lib/libdoctest.tex +++ b/Doc/lib/libdoctest.tex @@ -201,6 +201,19 @@ prohibit it by passing \code{verbose=False}. In either of those cases, \code{sys.argv} is not examined by \function{testmod()} (so passing \programopt{-v} or not has no effect). +Since Python 2.6, there is also a command line shortcut for running +\function{testmod()}. You can instruct the Python interpreter to run +the doctest module directly from the standard library and pass the module +name(s) on the command line: + +\begin{verbatim} +python -m doctest -v example.py +\end{verbatim} + +This will import \file{example.py} as a standalone module and run +\function{testmod()} on it. Note that this may not work correctly if the +file is part of a package and imports other submodules from that package. + For more information on \function{testmod()}, see section~\ref{doctest-basic-api}. @@ -267,6 +280,18 @@ Like \function{testmod()}, \function{testfile()}'s verbosity can be set with the \programopt{-v} command-line switch or with the optional keyword argument \var{verbose}. +Since Python 2.6, there is also a command line shortcut for running +\function{testfile()}. You can instruct the Python interpreter to run +the doctest module directly from the standard library and pass the file +name(s) on the command line: + +\begin{verbatim} +python -m doctest -v example.txt +\end{verbatim} + +Because the file name does not end with \file{.py}, \module{doctest} infers +that it must be run with \function{testfile()}, not \function{testmod()}. + For more information on \function{testfile()}, see section~\ref{doctest-basic-api}. @@ -1716,7 +1741,7 @@ Doctest provides several mechanisms for debugging doctest examples: >>> \end{verbatim} - \versionchanged[The ability to use \code{\refmodule{pdb}.set_trace()} + \versionchanged[The ability to use \function{\refmodule{pdb}.set_trace()} usefully inside doctests was added]{2.4} \end{itemize} @@ -1800,10 +1825,10 @@ print doctest.testsource(a, "a.f") used. If \var{pm} has a true value, the script file is run directly, and the debugger gets involved only if the script terminates via raising an unhandled exception. If it does, then post-mortem debugging is invoked, - via \code{\refmodule{pdb}.post_mortem()}, passing the traceback object + via \function{\refmodule{pdb}.post_mortem()}, passing the traceback object from the unhandled exception. If \var{pm} is not specified, or is false, the script is run under the debugger from the start, via passing an - appropriate \function{execfile()} call to \code{\refmodule{pdb}.run()}. + appropriate \function{execfile()} call to \function{\refmodule{pdb}.run()}. \versionadded{2.3} |