diff options
author | Fred Drake <fdrake@acm.org> | 2001-06-11 14:57:07 (GMT) |
---|---|---|
committer | Fred Drake <fdrake@acm.org> | 2001-06-11 14:57:07 (GMT) |
commit | a623ca8f8032d0b8b1312e5eb0d0c799922f5efd (patch) | |
tree | 0136cfc568653acbc38e6016104446e7290e0e1c | |
parent | ceea6feb35751c9e4e36f4689affa9465d249f23 (diff) | |
download | cpython-a623ca8f8032d0b8b1312e5eb0d0c799922f5efd.zip cpython-a623ca8f8032d0b8b1312e5eb0d0c799922f5efd.tar.gz cpython-a623ca8f8032d0b8b1312e5eb0d0c799922f5efd.tar.bz2 |
Merge in recent changes from development branch: add warning about being
sure that code only runs once when using the module as both a module and a
script.
-rw-r--r-- | Doc/lib/libdoctest.tex | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex index 6d19259..9b99b9d 100644 --- a/Doc/lib/libdoctest.tex +++ b/Doc/lib/libdoctest.tex @@ -406,6 +406,17 @@ often contrive doctest examples to produce numbers of that form: Simple fractions are also easier for people to understand, and that makes for better documentation. + +\item Be careful if you have code that must only execute once. + +If you have module-level code that must only execute once, a more foolproof +definition of \function{_test()} is + +\begin{verbatim} +def _test(): + import doctest, sys + doctest.testmod(sys.modules["__main__"]) +\end{verbatim} \end{enumerate} |