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

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


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

Modified Files:
	regrtest.py test_support.py 
Log Message:
Guido points out that sys.__stdout__ is a bit bucket under IDLE.  So keep
the local save/modify/restore of sys.stdout, but add machinery so that
regrtest can tell test_support the value of sys.stdout at the time
regrtest.main() started, and test_support can pass that out later to anyone
who needs a "visible" stdout.


Index: regrtest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/regrtest.py,v
retrieving revision 1.56
retrieving revision 1.57
diff -C2 -d -r1.56 -r1.57
*** regrtest.py	2001/09/25 19:13:20	1.56
--- regrtest.py	2001/09/25 20:05:11	1.57
***************
*** 86,89 ****
--- 86,90 ----
      """
  
+     test_support.record_original_stdout(sys.stdout)
      try:
          opts, args = getopt.getopt(sys.argv[1:], 'hvgqxsrlu:',

Index: test_support.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_support.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** test_support.py	2001/09/25 19:13:20	1.36
--- test_support.py	2001/09/25 20:05:11	1.37
***************
*** 22,25 ****
--- 22,36 ----
  use_resources = None       # Flag set to [] by regrtest.py
  
+ # _original_stdout is meant to hold stdout at the time regrtest began.
+ # This may be "the real" stdout, or IDLE's emulation of stdout, or whatever.
+ # The point is to have some flavor of stdout the user can actually see.
+ _original_stdout = None
+ def record_original_stdout(stdout):
+     global _original_stdout
+     _original_stdout = stdout
+ 
+ def get_original_stdout():
+     return _original_stdout or sys.stdout
+ 
  def unload(name):
      try:
***************
*** 183,187 ****
      # output shouldn't be compared by regrtest.
      save_stdout = sys.stdout
!     sys.stdout = sys.__stdout__
      try:
          f, t = doctest.testmod(module, verbose=verbosity)
--- 194,198 ----
      # output shouldn't be compared by regrtest.
      save_stdout = sys.stdout
!     sys.stdout = get_original_stdout()
      try:
          f, t = doctest.testmod(module, verbose=verbosity)