[Python-checkins] python/dist/src/Lib doctest.py,1.53,1.54

dcjim at users.sourceforge.net dcjim at users.sourceforge.net
Mon Aug 9 13:34:49 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13178/Lib

Modified Files:
	doctest.py 
Log Message:
Added support for pdb.set_trace.


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** doctest.py	9 Aug 2004 04:34:45 -0000	1.53
--- doctest.py	9 Aug 2004 11:34:47 -0000	1.54
***************
*** 188,195 ****
  
  import sys, traceback, inspect, linecache, os, re, types
! import unittest, difflib, tempfile
  import warnings
  from StringIO import StringIO
  
  # Option constants.
  DONT_ACCEPT_TRUE_FOR_1 = 1 << 0
--- 188,197 ----
  
  import sys, traceback, inspect, linecache, os, re, types
! import unittest, difflib, pdb, tempfile
  import warnings
  from StringIO import StringIO
  
+ real_pdb_set_trace = pdb.set_trace
+ 
  # Option constants.
  DONT_ACCEPT_TRUE_FOR_1 = 1 << 0
***************
*** 1252,1264 ****
--- 1254,1279 ----
          if compileflags is None:
              compileflags = _extract_future_flags(test.globs)
+ 
          if out is None:
              out = sys.stdout.write
          saveout = sys.stdout
  
+         # Note that don't save away the previous pdb.set_trace. Rather,
+         # we safe pdb.set_trace on import (see import section above).
+         # We then call and restore that original cersion.  We do it this
+         # way to make this feature testable.  If we kept and called the
+         # previous version, we'd end up restoring the original stdout,
+         # which is not what we want.
+         def set_trace():
+             sys.stdout = saveout
+             real_pdb_set_trace()
+ 
          try:
              sys.stdout = self._fakeout
+             pdb.set_trace = set_trace
              return self.__run(test, compileflags, out)
          finally:
              sys.stdout = saveout
+             pdb.set_trace = real_pdb_set_trace
              if clear_globs:
                  test.globs.clear()



More information about the Python-checkins mailing list