diff options
author | Guido van Rossum <guido@python.org> | 2007-04-17 02:38:04 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2007-04-17 02:38:04 (GMT) |
commit | d76e7796c97a8f4d555a687609bd96f01f68b7a1 (patch) | |
tree | 7e93e6ec7945842c719a09598b6cfe7f3e6732b2 /Lib/test/test_io.py | |
parent | 3abcb013b8195aea38f80968d4111b5ac7e68c0b (diff) | |
download | cpython-d76e7796c97a8f4d555a687609bd96f01f68b7a1.zip cpython-d76e7796c97a8f4d555a687609bd96f01f68b7a1.tar.gz cpython-d76e7796c97a8f4d555a687609bd96f01f68b7a1.tar.bz2 |
Instead of pickling the whole decoder, use the new getstate/setstate API.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r-- | Lib/test/test_io.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py index 1f6be02..0b63fee 100644 --- a/Lib/test/test_io.py +++ b/Lib/test/test_io.py @@ -581,6 +581,36 @@ class TextIOWrapperTest(unittest.TestCase): self.assertEquals(f.tell(), p2) f.close() + def testSeeking(self): + chunk_size = io.TextIOWrapper._CHUNK_SIZE + prefix_size = chunk_size - 2 + u_prefix = u"a" * prefix_size + prefix = bytes(u_prefix.encode("utf-8")) + self.assertEquals(len(u_prefix), len(prefix)) + u_suffix = u"\u8888\n" + suffix = bytes(u_suffix.encode("utf-8")) + line = prefix + suffix + f = io.open(test_support.TESTFN, "wb") + f.write(line*2) + f.close() + f = io.open(test_support.TESTFN, "r", encoding="utf-8") + s = f.read(prefix_size) + self.assertEquals(s, prefix) + self.assertEquals(f.tell(), prefix_size) + self.assertEquals(f.readline(), u_suffix) + + def testSeekingToo(self): + # Regression test for a specific bug + data = b'\xe0\xbf\xbf\n' + f = io.open(test_support.TESTFN, "wb") + f.write(data) + f.close() + f = io.open(test_support.TESTFN, "r", encoding="utf-8") + f._CHUNK_SIZE # Just test that it exists + f._CHUNK_SIZE = 2 + f.readline() + f.tell() + def timingTest(self): timer = time.time enc = "utf8" |