[Python-checkins] python/dist/src/Lib/test test_codecs.py, 1.23, 1.24

doerwalter@users.sourceforge.net doerwalter at users.sourceforge.net
Thu Jul 21 00:15:42 CEST 2005


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28950/Lib/test

Modified Files:
	test_codecs.py 
Log Message:
Make attributes and local variables in the StreamReader str objects instead
of unicode objects, so that codecs that do a str->str decoding won't promote
the result to unicode. This fixes SF bug #1241507.


Index: test_codecs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_codecs.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- test_codecs.py	21 Apr 2005 21:45:36 -0000	1.23
+++ test_codecs.py	20 Jul 2005 22:15:39 -0000	1.24
@@ -663,6 +663,22 @@
         f = self.reader(self.stream)
         self.assertEquals(f.readlines(), [u'\ud55c\n', u'\uae00'])
 
+class Str2StrTest(unittest.TestCase):
+
+    def test_read(self):
+        sin = "\x80".encode("base64_codec")
+        reader = codecs.getreader("base64_codec")(StringIO.StringIO(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.StringIO(sin))
+        sout = reader.readline()
+        self.assertEqual(sout, "\x80")
+        self.assert_(isinstance(sout, str))
+
 all_unicode_encodings = [
     "ascii",
     "base64_codec",
@@ -867,6 +883,7 @@
         CodecTest,
         CodecsModuleTest,
         StreamReaderTest,
+        Str2StrTest,
         BasicUnicodeTest,
         BasicStrTest
     )



More information about the Python-checkins mailing list