Back to index

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

List of all members.

Public Member Functions

def test_stateless
def test_stateful
def test_stateful_keep_buffer
def test_issue5640

Detailed Description

Definition at line 68 of file test_multibytecodec.py.


Member Function Documentation

Definition at line 114 of file test_multibytecodec.py.

00114 
00115     def test_issue5640(self):
00116         encoder = codecs.getincrementalencoder('shift-jis')('backslashreplace')
00117         self.assertEqual(encoder.encode('\xff'), b'\\xff')
00118         self.assertEqual(encoder.encode('\n'), b'\n')

Here is the call graph for this function:

Definition at line 83 of file test_multibytecodec.py.

00083 
00084     def test_stateful(self):
00085         # jisx0213 encoder is stateful for a few codepoints. eg)
00086         #   U+00E6 => A9DC
00087         #   U+00E6 U+0300 => ABC4
00088         #   U+0300 => ABDC
00089 
00090         encoder = codecs.getincrementalencoder('jisx0213')()
00091         self.assertEqual(encoder.encode('\u00e6\u0300'), b'\xab\xc4')
00092         self.assertEqual(encoder.encode('\u00e6'), b'')
00093         self.assertEqual(encoder.encode('\u0300'), b'\xab\xc4')
00094         self.assertEqual(encoder.encode('\u00e6', True), b'\xa9\xdc')
00095 
00096         self.assertEqual(encoder.reset(), None)
00097         self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc')
00098 
00099         self.assertEqual(encoder.encode('\u00e6'), b'')
00100         self.assertEqual(encoder.encode('', True), b'\xa9\xdc')
00101         self.assertEqual(encoder.encode('', True), b'')

Here is the call graph for this function:

Definition at line 102 of file test_multibytecodec.py.

00102 
00103     def test_stateful_keep_buffer(self):
00104         encoder = codecs.getincrementalencoder('jisx0213')()
00105         self.assertEqual(encoder.encode('\u00e6'), b'')
00106         self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
00107         self.assertEqual(encoder.encode('\u0300\u00e6'), b'\xab\xc4')
00108         self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
00109         self.assertEqual(encoder.reset(), None)
00110         self.assertEqual(encoder.encode('\u0300'), b'\xab\xdc')
00111         self.assertEqual(encoder.encode('\u00e6'), b'')
00112         self.assertRaises(UnicodeEncodeError, encoder.encode, '\u0123')
00113         self.assertEqual(encoder.encode('', True), b'\xa9\xdc')

Here is the call graph for this function:

Definition at line 70 of file test_multibytecodec.py.

00070 
00071     def test_stateless(self):
00072         # cp949 encoder isn't stateful at all.
00073         encoder = codecs.getincrementalencoder('cp949')()
00074         self.assertEqual(encoder.encode('\ud30c\uc774\uc36c \ub9c8\uc744'),
00075                          b'\xc6\xc4\xc0\xcc\xbd\xe3 \xb8\xb6\xc0\xbb')
00076         self.assertEqual(encoder.reset(), None)
00077         self.assertEqual(encoder.encode('\u2606\u223c\u2606', True),
00078                          b'\xa1\xd9\xa1\xad\xa1\xd9')
00079         self.assertEqual(encoder.reset(), None)
00080         self.assertEqual(encoder.encode('', True), b'')
00081         self.assertEqual(encoder.encode('', False), b'')
00082         self.assertEqual(encoder.reset(), None)

Here is the call graph for this function:


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