summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_argparse.py
diff options
context:
space:
mode:
authorMichael Foord <fuzzyman@voidspace.org.uk>2010-04-08 00:04:24 (GMT)
committerMichael Foord <fuzzyman@voidspace.org.uk>2010-04-08 00:04:24 (GMT)
commit91a2c89288125b9509ce3fa8436f49a029031be4 (patch)
treed6552bd9c4f156ab3003cf3d3543a16ba176b02c /Lib/test/test_argparse.py
parentf6ff26c486373dcb6c9ee2f4aae102202e89b722 (diff)
downloadcpython-91a2c89288125b9509ce3fa8436f49a029031be4.zip
cpython-91a2c89288125b9509ce3fa8436f49a029031be4.tar.gz
cpython-91a2c89288125b9509ce3fa8436f49a029031be4.tar.bz2
Switch regrtest to use StringIO instead of cStringIO for test_multiprocessing on Windows. Issue 8333.
Diffstat (limited to 'Lib/test/test_argparse.py')
-rw-r--r--Lib/test/test_argparse.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index cefae25..6f1b714 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -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)