mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
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:
parent
23105d5c24
commit
f853be980e
2 changed files with 23 additions and 5 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue