add warning about situation where code may be executed twice, once when
module is __main__ and once when module is imported.
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex
index 6d19259..30833da 100644
--- a/Doc/lib/libdoctest.tex
+++ b/Doc/lib/libdoctest.tex
@@ -408,6 +408,16 @@
for better documentation.
\end{enumerate}
+\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}
\subsection{Soapbox}