Back to index

python3.2  3.2.2
Public Member Functions
test.test_codecs.MixInCheckStateHandling Class Reference
Inheritance diagram for test.test_codecs.MixInCheckStateHandling:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def check_state_handling_decode
def check_state_handling_encode

Detailed Description

Definition at line 27 of file test_codecs.py.


Member Function Documentation

Definition at line 28 of file test_codecs.py.

00028 
00029     def check_state_handling_decode(self, encoding, u, s):
00030         for i in range(len(s)+1):
00031             d = codecs.getincrementaldecoder(encoding)()
00032             part1 = d.decode(s[:i])
00033             state = d.getstate()
00034             self.assertIsInstance(state[1], int)
00035             # Check that the condition stated in the documentation for
00036             # IncrementalDecoder.getstate() holds
00037             if not state[1]:
00038                 # reset decoder to the default state without anything buffered
00039                 d.setstate((state[0][:0], 0))
00040                 # Feeding the previous input may not produce any output
00041                 self.assertTrue(not d.decode(state[0]))
00042                 # The decoder must return to the same state
00043                 self.assertEqual(state, d.getstate())
00044             # Create a new decoder and set it to the state
00045             # we extracted from the old one
00046             d = codecs.getincrementaldecoder(encoding)()
00047             d.setstate(state)
00048             part2 = d.decode(s[i:], True)
00049             self.assertEqual(u, part1+part2)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 50 of file test_codecs.py.

00050 
00051     def check_state_handling_encode(self, encoding, u, s):
00052         for i in range(len(u)+1):
00053             d = codecs.getincrementalencoder(encoding)()
00054             part1 = d.encode(u[:i])
00055             state = d.getstate()
00056             d = codecs.getincrementalencoder(encoding)()
00057             d.setstate(state)
00058             part2 = d.encode(u[i:], True)
00059             self.assertEqual(s, part1+part2)

Here is the call graph for this function:

Here is the caller graph for this function:


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