cpython: 78cd09d2f908 (original) (raw)
Mercurial > cpython
changeset 83256:78cd09d2f908
Issue #13056: Reenable test_multibytecodec.Test_StreamWriter tests [#13056]
Victor Stinner victor.stinner@gmail.com | |
---|---|
date | Thu, 11 Apr 2013 22:41:11 +0200 |
parents | bcecf3910162 |
children | c84a5e5f73c3 |
files | Lib/test/test_multibytecodec.py |
diffstat | 1 files changed, 21 insertions(+), 50 deletions(-)[+] [-] Lib/test/test_multibytecodec.py 71 |
line wrap: on
line diff
--- a/Lib/test/test_multibytecodec.py +++ b/Lib/test/test_multibytecodec.py @@ -176,57 +176,28 @@ class Test_StreamReader(unittest.TestCas support.unlink(TESTFN) class Test_StreamWriter(unittest.TestCase):
- if len('\U00012345') == 2: # UCS2
def test_gb18030(self):[](#l1.8)
s= io.BytesIO()[](#l1.9)
c = codecs.getwriter('gb18030')(s)[](#l1.10)
c.write('123')[](#l1.11)
self.assertEqual(s.getvalue(), b'123')[](#l1.12)
c.write('\U00012345')[](#l1.13)
self.assertEqual(s.getvalue(), b'123\x907\x959')[](#l1.14)
c.write('\U00012345'[0])[](#l1.15)
self.assertEqual(s.getvalue(), b'123\x907\x959')[](#l1.16)
c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')[](#l1.17)
self.assertEqual(s.getvalue(),[](#l1.18)
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')[](#l1.19)
c.write('\U00012345'[0])[](#l1.20)
self.assertEqual(s.getvalue(),[](#l1.21)
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')[](#l1.22)
self.assertRaises(UnicodeError, c.reset)[](#l1.23)
self.assertEqual(s.getvalue(),[](#l1.24)
b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')[](#l1.25)
- def test_gb18030(self):
s= io.BytesIO()[](#l1.27)
c = codecs.getwriter('gb18030')(s)[](#l1.28)
c.write('123')[](#l1.29)
self.assertEqual(s.getvalue(), b'123')[](#l1.30)
c.write('\U00012345')[](#l1.31)
self.assertEqual(s.getvalue(), b'123\x907\x959')[](#l1.32)
c.write('\uac00\u00ac')[](#l1.33)
self.assertEqual(s.getvalue(),[](#l1.34)
b'123\x907\x959\x827\xcf5\x810\x851')[](#l1.35)
def test_utf_8(self):[](#l1.37)
s= io.BytesIO()[](#l1.38)
c = codecs.getwriter('utf-8')(s)[](#l1.39)
c.write('123')[](#l1.40)
self.assertEqual(s.getvalue(), b'123')[](#l1.41)
c.write('\U00012345')[](#l1.42)
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')[](#l1.43)
# Python utf-8 codec can't buffer surrogate pairs yet.[](#l1.45)
if 0:[](#l1.46)
c.write('\U00012345'[0])[](#l1.47)
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')[](#l1.48)
c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')[](#l1.49)
self.assertEqual(s.getvalue(),[](#l1.50)
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'[](#l1.51)
b'\xea\xb0\x80\xc2\xac')[](#l1.52)
c.write('\U00012345'[0])[](#l1.53)
self.assertEqual(s.getvalue(),[](#l1.54)
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'[](#l1.55)
b'\xea\xb0\x80\xc2\xac')[](#l1.56)
c.reset()[](#l1.57)
self.assertEqual(s.getvalue(),[](#l1.58)
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'[](#l1.59)
b'\xea\xb0\x80\xc2\xac\xed\xa0\x88')[](#l1.60)
c.write('\U00012345'[1])[](#l1.61)
self.assertEqual(s.getvalue(),[](#l1.62)
b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'[](#l1.63)
b'\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85')[](#l1.64)
- def test_utf_8(self):
s= io.BytesIO()[](#l1.69)
c = codecs.getwriter('utf-8')(s)[](#l1.70)
c.write('123')[](#l1.71)
self.assertEqual(s.getvalue(), b'123')[](#l1.72)
c.write('\U00012345')[](#l1.73)
self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')[](#l1.74)
c.write('\uac00\u00ac')[](#l1.75)
self.assertEqual(s.getvalue(),[](#l1.76)
b'123\xf0\x92\x8d\x85'[](#l1.77)
b'\xea\xb0\x80\xc2\xac')[](#l1.78)