Back to index

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

List of all members.

Public Member Functions

def test_dbcs
def test_dbcs_keep_buffer
def test_iso2022
def test_decode_unicode

Detailed Description

Definition at line 119 of file test_multibytecodec.py.


Member Function Documentation

Definition at line 121 of file test_multibytecodec.py.

00121 
00122     def test_dbcs(self):
00123         # cp949 decoder is simple with only 1 or 2 bytes sequences.
00124         decoder = codecs.getincrementaldecoder('cp949')()
00125         self.assertEqual(decoder.decode(b'\xc6\xc4\xc0\xcc\xbd'),
00126                          '\ud30c\uc774')
00127         self.assertEqual(decoder.decode(b'\xe3 \xb8\xb6\xc0\xbb'),
00128                          '\uc36c \ub9c8\uc744')
00129         self.assertEqual(decoder.decode(b''), '')

Here is the call graph for this function:

Definition at line 130 of file test_multibytecodec.py.

00130 
00131     def test_dbcs_keep_buffer(self):
00132         decoder = codecs.getincrementaldecoder('cp949')()
00133         self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c')
00134         self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True)
00135         self.assertEqual(decoder.decode(b'\xcc'), '\uc774')
00136 
00137         self.assertEqual(decoder.decode(b'\xc6\xc4\xc0'), '\ud30c')
00138         self.assertRaises(UnicodeDecodeError, decoder.decode,
00139                           b'\xcc\xbd', True)
00140         self.assertEqual(decoder.decode(b'\xcc'), '\uc774')

Here is the call graph for this function:

Definition at line 156 of file test_multibytecodec.py.

00156 
00157     def test_decode_unicode(self):
00158         # Trying to decode an unicode string should raise a TypeError
00159         for enc in ALL_CJKENCODINGS:
00160             decoder = codecs.getincrementaldecoder(enc)()
00161             self.assertRaises(TypeError, decoder.decode, "")

Here is the call graph for this function:

Definition at line 141 of file test_multibytecodec.py.

00141 
00142     def test_iso2022(self):
00143         decoder = codecs.getincrementaldecoder('iso2022-jp')()
00144         ESC = b'\x1b'
00145         self.assertEqual(decoder.decode(ESC + b'('), '')
00146         self.assertEqual(decoder.decode(b'B', True), '')
00147         self.assertEqual(decoder.decode(ESC + b'$'), '')
00148         self.assertEqual(decoder.decode(b'B@$'), '\u4e16')
00149         self.assertEqual(decoder.decode(b'@$@'), '\u4e16')
00150         self.assertEqual(decoder.decode(b'$', True), '\u4e16')
00151         self.assertEqual(decoder.reset(), None)
00152         self.assertEqual(decoder.decode(b'@$'), '@$')
00153         self.assertEqual(decoder.decode(ESC + b'$'), '')
00154         self.assertRaises(UnicodeDecodeError, decoder.decode, b'', True)
00155         self.assertEqual(decoder.decode(b'B@$'), '\u4e16')

Here is the call graph for this function:


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