[Python-checkins] CVS: python/dist/src/Doc/lib libdoctest.tex,1.8,1.9

Tim Peters tim_one@users.sourceforge.net
2001年10月02日 14:01:24 -0700


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv26155/python/Doc/lib
Modified Files:
	libdoctest.tex 
Log Message:
CVS patch [#466628] Doc changes for doctest patch (#466616), from
Tim Hochberg. Doctest no longer searches imported objects.
Index: libdoctest.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libdoctest.tex,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** libdoctest.tex	2001年06月11日 14:55:01	1.8
--- libdoctest.tex	2001年10月02日 21:01:22	1.9
***************
*** 187,191 ****
 module docstring, and all function, class and method docstrings are
 searched, with the exception of docstrings attached to objects with private
! names.
 
 In addition, if \code{M.__test__} exists and "is true", it must be a
--- 187,191 ----
 module docstring, and all function, class and method docstrings are
 searched, with the exception of docstrings attached to objects with private
! names. Objects imported into the module are not searched.
 
 In addition, if \code{M.__test__} exists and "is true", it must be a
***************
*** 212,218 ****
 \module{M} can't leave behind crumbs that accidentally allow another test
 to work. This means examples can freely use any names defined at top-level
! in \module{M}, and names defined earlier in the docstring being run. It
! also means that sloppy imports (see below) can cause examples in external
! docstrings to use globals inappropriate for them.
 
 You can force use of your own dict as the execution context by passing
--- 212,216 ----
 \module{M} can't leave behind crumbs that accidentally allow another test
 to work. This means examples can freely use any names defined at top-level
! in \module{M}, and names defined earlier in the docstring being run.
 
 You can force use of your own dict as the execution context by passing
***************
*** 320,344 ****
 
 \begin{enumerate}
- 
- \item Sloppy imports can cause trouble; e.g., if you do
- 
- \begin{verbatim}
- from XYZ import XYZclass
- \end{verbatim}
- 
- then \class{XYZclass} is a name in \code{M.__dict__} too, and doctest
- has no way to know that \class{XYZclass} wasn't \emph{defined} in
- \module{M}. So it may try to execute the examples in
- \class{XYZclass}'s docstring, and those in turn may require a
- different set of globals to work correctly. I prefer to do
- ``\code{import *}''-friendly imports, a la
- 
- \begin{verbatim}
- from XYZ import XYZclass as _XYZclass
- \end{verbatim}
- 
- and then the leading underscore makes \class{_XYZclass} a private name so
- testmod skips it by default. Other approaches are described in
- \file{doctest.py}.
 
 \item \module{doctest} is serious about requiring exact matches in expected
--- 318,321 ----

AltStyle によって変換されたページ (->オリジナル) /