(self, encoding, u, s)
| 80 | |
| 81 | class MixInCheckStateHandling: |
| 82 | def check_state_handling_decode(self, encoding, u, s): |
| 83 | for i in range(len(s)+1): |
| 84 | d = codecs.getincrementaldecoder(encoding)() |
| 85 | part1 = d.decode(s[:i]) |
| 86 | state = d.getstate() |
| 87 | self.assertIsInstance(state[1], int) |
| 88 | # Check that the condition stated in the documentation for |
| 89 | # IncrementalDecoder.getstate() holds |
| 90 | if not state[1]: |
| 91 | # reset decoder to the default state without anything buffered |
| 92 | d.setstate((state[0][:0], 0)) |
| 93 | # Feeding the previous input may not produce any output |
| 94 | self.assertTrue(not d.decode(state[0])) |
| 95 | # The decoder must return to the same state |
| 96 | self.assertEqual(state, d.getstate()) |
| 97 | # Create a new decoder and set it to the state |
| 98 | # we extracted from the old one |
| 99 | d = codecs.getincrementaldecoder(encoding)() |
| 100 | d.setstate(state) |
| 101 | part2 = d.decode(s[i:], True) |
| 102 | self.assertEqual(u, part1+part2) |
| 103 | |
| 104 | def check_state_handling_encode(self, encoding, u, s): |
| 105 | for i in range(len(u)+1): |
no test coverage detected