]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
It's merge time!
authorMichael W. Hudson <mwh@python.net>
Mon, 28 Jan 2002 15:01:42 +0000 (15:01 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 28 Jan 2002 15:01:42 +0000 (15:01 +0000)
Backport lemburg's checkin of revision 1.11:

Restore Python 2.1 StringIO.py behaviour: support concatenating
Unicode string snippets to larger Unicode strings.

This fix should also go into Python 2.2.1.

Lib/test/test_StringIO.py

index 8b934fffcdfe1151ca4972ea7f328be247b27728..bf3640cf75e56983ef1c382e044c3d5350abda02 100644 (file)
@@ -71,6 +71,21 @@ class TestGenericStringIO(unittest.TestCase):
 class TestStringIO(TestGenericStringIO):
     MODULE = StringIO
 
+    def test_unicode(self):
+
+        # The StringIO module also supports concatenating Unicode
+        # snippets to larger Unicode strings. This is tested by this
+        # method. Note that cStringIO does not support this extension.
+        
+        f = self.MODULE.StringIO()
+        f.write(self._line[:6])
+        f.seek(3)
+        f.write(unicode(self._line[20:26]))
+        f.write(unicode(self._line[52]))
+        s = f.getvalue()
+        self.assertEqual(s, unicode('abcuvwxyz!'))
+        self.assertEqual(type(s), types.UnicodeType)
+
 class TestcStringIO(TestGenericStringIO):
     MODULE = cStringIO