From 9d2ac227210fa8c7ba14a581747d1a1836e7274c Mon Sep 17 00:00:00 2001 From: Walter Dörwald Date: Wed, 16 May 2007 12:47:53 +0000 Subject: Fix io.StringIO: String are stored encoded (using "unicode-internal" as the encoding) which makes the buffer mutable. Strings are encoded on the way in and decoded on the way out. Use io.StringIO in test_codecs.py. Fix the base64_codec test in test_codecs.py. --- Lib/test/test_codecs.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'Lib/test/test_codecs.py') diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index f61cc33a4f6..03be34c7e1c 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2,7 +2,6 @@ from test import test_support import unittest import codecs import sys, _testcapi, io -from StringIO import StringIO class Queue(object): """ @@ -493,7 +492,7 @@ class EscapeDecodeTest(unittest.TestCase): class RecodingTest(unittest.TestCase): def test_recoding(self): - f = StringIO() + f = io.StringIO() f2 = codecs.EncodedFile(f, "unicode_internal", "utf-8") f2.write("a") f2.close() @@ -991,14 +990,14 @@ class Str2StrTest(unittest.TestCase): def test_read(self): sin = "\x80".encode("base64_codec") - reader = codecs.getreader("base64_codec")(StringIO(sin)) + reader = codecs.getreader("base64_codec")(io.BytesIO(sin)) sout = reader.read() self.assertEqual(sout, "\x80") self.assert_(isinstance(sout, str)) def test_readline(self): sin = "\x80".encode("base64_codec") - reader = codecs.getreader("base64_codec")(StringIO(sin)) + reader = codecs.getreader("base64_codec")(io.BytesIO(sin)) sout = reader.readline() self.assertEqual(sout, "\x80") self.assert_(isinstance(sout, str)) -- cgit v1.2.3