[Python-checkins] CVS: python/dist/src/Lib/test regrtest.py,1.55,1.56 test_support.py,1.35,1.36

Tim Peters tim_one@users.sourceforge.net
Tue, 25 Sep 2001 12:13:22 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv21254/python/Lib/test

Modified Files:
	regrtest.py test_support.py 
Log Message:
Get rid of the increasingly convoluted global tricks w/ sys.stdout, in
favor of local save/modify/restore.  The test suite should run fine again.


Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** regrtest.py	2001/09/22 05:31:03	1.55
--- regrtest.py	2001/09/25 19:13:20	1.56
***************
*** 288,292 ****
          cfp =  StringIO.StringIO()
      try:
!         sys.save_stdout = sys.stdout
          try:
              if cfp:
--- 288,292 ----
          cfp =  StringIO.StringIO()
      try:
!         save_stdout = sys.stdout
          try:
              if cfp:
***************
*** 302,306 ****
                  indirect_test()
          finally:
!             sys.stdout = sys.save_stdout
      except (ImportError, test_support.TestSkipped), msg:
          if not quiet:
--- 302,306 ----
                  indirect_test()
          finally:
!             sys.stdout = save_stdout
      except (ImportError, test_support.TestSkipped), msg:
          if not quiet:

Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** test_support.py	2001/09/25 16:21:39	1.35
--- test_support.py	2001/09/25 19:13:20	1.36
***************
*** 3,8 ****
  import sys
  
- sys.save_stdout = sys.stdout
- 
  class Error(Exception):
      """Base class for regression test exceptions."""
--- 3,6 ----
***************
*** 24,47 ****
  use_resources = None       # Flag set to [] by regrtest.py
  
- # _output_comparison controls whether regrtest will try to compare stdout
- # with an expected-output file.  For straight regrtests, it should.
- # The doctest driver resets this flag by calling deny_output_comparison().
- # Note that this control is in addition to verbose mode:  output will be
- # compared if and only if _output_comparison is true and verbose mode is
- # not in effect.
- _output_comparison = 1
- 
- def deny_output_comparison():
-     global _output_comparison
-     _output_comparison = 0
-     sys.stdout = sys.save_stdout
- 
- # regrtest's interface to _output_comparison.
- def output_comparison_denied():
-     global _output_comparison
-     denied = not _output_comparison
-     _output_comparison = 1
-     return denied
- 
  def unload(name):
      try:
--- 22,25 ----
***************
*** 202,207 ****
          verbosity = None
  
!     deny_output_comparison()
!     f, t = doctest.testmod(module, verbose=verbosity)
!     if f:
!         raise TestFailed("%d of %d doctests failed" % (f, t))
--- 180,191 ----
          verbosity = None
  
!     # Direct doctest output (normally just errors) to real stdout; doctest
!     # output shouldn't be compared by regrtest.
!     save_stdout = sys.stdout
!     sys.stdout = sys.__stdout__
!     try:
!         f, t = doctest.testmod(module, verbose=verbosity)
!         if f:
!             raise TestFailed("%d of %d doctests failed" % (f, t))
!     finally:
!         sys.stdout = save_stdout