[Python-checkins] python/dist/src/Lib doctest.py,1.24,1.25

loewis@users.sourceforge.net loewis@users.sourceforge.net
Fri, 22 Nov 2002 00:23:11 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv10492/Lib

Modified Files:
	doctest.py 
Log Message:
Patch #486438: Make module argument to testmod optional.


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** doctest.py	1 Jun 2002 14:18:45 -0000	1.24
--- doctest.py	22 Nov 2002 08:23:09 -0000	1.25
***************
*** 1045,1054 ****
  master = None
  
! def testmod(m, name=None, globs=None, verbose=None, isprivate=None,
                 report=1):
!     """m, name=None, globs=None, verbose=None, isprivate=None, report=1
  
!     Test examples in docstrings in functions and classes reachable from
!     module m, starting with m.__doc__.  Private names are skipped.
  
      Also test examples reachable from dict m.__test__ if it exists and is
--- 1045,1055 ----
  master = None
  
! def testmod(m=None, name=None, globs=None, verbose=None, isprivate=None,
                 report=1):
!     """m=None, name=None, globs=None, verbose=None, isprivate=None, report=1
  
!     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__.  Private names are skipped.
  
      Also test examples reachable from dict m.__test__ if it exists and is
***************
*** 1090,1093 ****
--- 1091,1101 ----
  
      global master
+ 
+     if m is None:
+         import sys
+         # DWA - m will still be None if this wasn't invoked from the command
+         # line, in which case the following TypeError is about as good an error
+         # as we should expect
+         m = sys.modules.get('__main__')
  
      if not _ismodule(m):