mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #13056: Reenable test_multibytecodec.Test_StreamWriter tests
This commit is contained in:
parent
a0dd0213cc
commit
eae41af356
1 changed files with 21 additions and 50 deletions
|
@ -176,57 +176,28 @@ class Test_StreamReader(unittest.TestCase):
|
||||||
support.unlink(TESTFN)
|
support.unlink(TESTFN)
|
||||||
|
|
||||||
class Test_StreamWriter(unittest.TestCase):
|
class Test_StreamWriter(unittest.TestCase):
|
||||||
if len('\U00012345') == 2: # UCS2
|
def test_gb18030(self):
|
||||||
def test_gb18030(self):
|
s= io.BytesIO()
|
||||||
s= io.BytesIO()
|
c = codecs.getwriter('gb18030')(s)
|
||||||
c = codecs.getwriter('gb18030')(s)
|
c.write('123')
|
||||||
c.write('123')
|
self.assertEqual(s.getvalue(), b'123')
|
||||||
self.assertEqual(s.getvalue(), b'123')
|
c.write('\U00012345')
|
||||||
c.write('\U00012345')
|
self.assertEqual(s.getvalue(), b'123\x907\x959')
|
||||||
self.assertEqual(s.getvalue(), b'123\x907\x959')
|
c.write('\uac00\u00ac')
|
||||||
c.write('\U00012345'[0])
|
self.assertEqual(s.getvalue(),
|
||||||
self.assertEqual(s.getvalue(), b'123\x907\x959')
|
b'123\x907\x959\x827\xcf5\x810\x851')
|
||||||
c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
|
|
||||||
c.write('\U00012345'[0])
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
|
|
||||||
self.assertRaises(UnicodeError, c.reset)
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
|
|
||||||
|
|
||||||
def test_utf_8(self):
|
def test_utf_8(self):
|
||||||
s= io.BytesIO()
|
s= io.BytesIO()
|
||||||
c = codecs.getwriter('utf-8')(s)
|
c = codecs.getwriter('utf-8')(s)
|
||||||
c.write('123')
|
c.write('123')
|
||||||
self.assertEqual(s.getvalue(), b'123')
|
self.assertEqual(s.getvalue(), b'123')
|
||||||
c.write('\U00012345')
|
c.write('\U00012345')
|
||||||
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
|
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
|
||||||
|
c.write('\uac00\u00ac')
|
||||||
# Python utf-8 codec can't buffer surrogate pairs yet.
|
self.assertEqual(s.getvalue(),
|
||||||
if 0:
|
b'123\xf0\x92\x8d\x85'
|
||||||
c.write('\U00012345'[0])
|
b'\xea\xb0\x80\xc2\xac')
|
||||||
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
|
|
||||||
c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
|
|
||||||
b'\xea\xb0\x80\xc2\xac')
|
|
||||||
c.write('\U00012345'[0])
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
|
|
||||||
b'\xea\xb0\x80\xc2\xac')
|
|
||||||
c.reset()
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
|
|
||||||
b'\xea\xb0\x80\xc2\xac\xed\xa0\x88')
|
|
||||||
c.write('\U00012345'[1])
|
|
||||||
self.assertEqual(s.getvalue(),
|
|
||||||
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
|
|
||||||
b'\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85')
|
|
||||||
|
|
||||||
else: # UCS4
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_streamwriter_strwrite(self):
|
def test_streamwriter_strwrite(self):
|
||||||
s = io.BytesIO()
|
s = io.BytesIO()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue