]> granicus.if.org Git - python/commitdiff
Switch regrtest to use StringIO instead of cStringIO for test_multiprocessing on...
authorMichael Foord <fuzzyman@voidspace.org.uk>
Thu, 8 Apr 2010 00:04:24 +0000 (00:04 +0000)
committerMichael Foord <fuzzyman@voidspace.org.uk>
Thu, 8 Apr 2010 00:04:24 +0000 (00:04 +0000)
Lib/test/regrtest.py
Lib/test/test_argparse.py

index 75716dce2f49a08fe492dba15ff4358d60c41c77..50519bfd025fa932f6aca77d6ace933478ba16d5 100755 (executable)
@@ -147,7 +147,7 @@ example, to run all the tests except for the bsddb tests, give the
 option '-uall,-bsddb'.
 """
 
-import cStringIO
+import StringIO
 import getopt
 import json
 import os
@@ -838,7 +838,7 @@ def runtest_inner(test, verbose, quiet,
     if verbose:
         capture_stdout = None
     else:
-        capture_stdout = cStringIO.StringIO()
+        capture_stdout = StringIO.StringIO()
 
     test_time = 0.0
     refleak = False  # True if the test leaked references.
index cefae25cb5397121442d077cf25c5730dc31e5a4..6f1b714ef250beaa024baba686abc7aa6ce11678 100644 (file)
@@ -11,6 +11,9 @@ import argparse
 
 from StringIO import StringIO
 
+class StdIOBuffer(StringIO):
+    pass
+
 from test import test_support
 
 class TestCase(unittest.TestCase):
@@ -25,6 +28,7 @@ class TestCase(unittest.TestCase):
         super(TestCase, self).assertEqual(obj1, obj2)
 
 
+
 class TempDirMixin(object):
 
     def setUp(self):
@@ -83,15 +87,15 @@ def stderr_to_parser_error(parse_args, *args, **kwargs):
     # if this is being called recursively and stderr or stdout is already being
     # redirected, simply call the function and let the enclosing function
     # catch the exception
-    if isinstance(sys.stderr, StringIO) or isinstance(sys.stdout, StringIO):
+    if isinstance(sys.stderr, StdIOBuffer) or isinstance(sys.stdout, StdIOBuffer):
         return parse_args(*args, **kwargs)
 
     # if this is not being called recursively, redirect stderr and
     # use it as the ArgumentParserError message
     old_stdout = sys.stdout
     old_stderr = sys.stderr
-    sys.stdout = StringIO()
-    sys.stderr = StringIO()
+    sys.stdout = StdIOBuffer()
+    sys.stderr = StdIOBuffer()
     try:
         try:
             result = parse_args(*args, **kwargs)
@@ -2644,7 +2648,7 @@ class TestHelpFormattingMetaclass(type):
                 parser = self._get_parser(tester)
                 print_ = getattr(parser, 'print_%s' % self.func_suffix)
                 old_stream = getattr(sys, self.std_name)
-                setattr(sys, self.std_name, StringIO())
+                setattr(sys, self.std_name, StdIOBuffer())
                 try:
                     print_()
                     parser_text = getattr(sys, self.std_name).getvalue()
@@ -2655,7 +2659,7 @@ class TestHelpFormattingMetaclass(type):
             def test_print_file(self, tester):
                 parser = self._get_parser(tester)
                 print_ = getattr(parser, 'print_%s' % self.func_suffix)
-                sfile = StringIO()
+                sfile = StdIOBuffer()
                 print_(sfile)
                 parser_text = sfile.getvalue()
                 self._test(tester, parser_text)