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.
This commit is contained in:
Marc-André Lemburg 2002-01-06 17:15:05 +00:00
parent 23105d5c24
commit f853be980e
2 changed files with 23 additions and 5 deletions

View 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