Back to index

python3.2  3.2.2
Public Member Functions
test.test_multibytecodec.Test_StreamWriter Class Reference

List of all members.

Public Member Functions

def test_gb18030
def test_utf_8
def test_streamwriter_strwrite

Detailed Description

Definition at line 178 of file test_multibytecodec.py.


Member Function Documentation

Definition at line 180 of file test_multibytecodec.py.

00180 
00181         def test_gb18030(self):
00182             s= io.BytesIO()
00183             c = codecs.getwriter('gb18030')(s)
00184             c.write('123')
00185             self.assertEqual(s.getvalue(), b'123')
00186             c.write('\U00012345')
00187             self.assertEqual(s.getvalue(), b'123\x907\x959')
00188             c.write('\U00012345'[0])
00189             self.assertEqual(s.getvalue(), b'123\x907\x959')
00190             c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
00191             self.assertEqual(s.getvalue(),
00192                     b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
00193             c.write('\U00012345'[0])
00194             self.assertEqual(s.getvalue(),
00195                     b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')
00196             self.assertRaises(UnicodeError, c.reset)
00197             self.assertEqual(s.getvalue(),
00198                     b'123\x907\x959\x907\x959\x907\x959\x827\xcf5\x810\x851')

Here is the call graph for this function:

Definition at line 231 of file test_multibytecodec.py.

00231 
00232     def test_streamwriter_strwrite(self):
00233         s = io.BytesIO()
00234         wr = codecs.getwriter('gb18030')(s)
00235         wr.write('abcd')
00236         self.assertEqual(s.getvalue(), b'abcd')

Here is the call graph for this function:

Definition at line 199 of file test_multibytecodec.py.

00199 
00200         def test_utf_8(self):
00201             s= io.BytesIO()
00202             c = codecs.getwriter('utf-8')(s)
00203             c.write('123')
00204             self.assertEqual(s.getvalue(), b'123')
00205             c.write('\U00012345')
00206             self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
00207 
00208             # Python utf-8 codec can't buffer surrogate pairs yet.
00209             if 0:
00210                 c.write('\U00012345'[0])
00211                 self.assertEqual(s.getvalue(), b'123\xf0\x92\x8d\x85')
00212                 c.write('\U00012345'[1] + '\U00012345' + '\uac00\u00ac')
00213                 self.assertEqual(s.getvalue(),
00214                     b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
00215                     b'\xea\xb0\x80\xc2\xac')
00216                 c.write('\U00012345'[0])
00217                 self.assertEqual(s.getvalue(),
00218                     b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
00219                     b'\xea\xb0\x80\xc2\xac')
00220                 c.reset()
00221                 self.assertEqual(s.getvalue(),
00222                     b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
00223                     b'\xea\xb0\x80\xc2\xac\xed\xa0\x88')
00224                 c.write('\U00012345'[1])
00225                 self.assertEqual(s.getvalue(),
00226                     b'123\xf0\x92\x8d\x85\xf0\x92\x8d\x85\xf0\x92\x8d\x85'
00227                     b'\xea\xb0\x80\xc2\xac\xed\xa0\x88\xed\xbd\x85')

Here is the call graph for this function:


The documentation for this class was generated from the following file: