summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2005-03-14 19:06:30 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2005-03-14 19:06:30 (GMT)
commit729c31f5c3e8dcbff571e066ab253db272e490a5 (patch)
tree1c9434e6f1411665bd3a0210cea4c64be87a89d3 /Lib/test/test_codecs.py
parent3390d33dd7d1fe4ce08a90f3a7f8759dfa101387 (diff)
downloadcpython-729c31f5c3e8dcbff571e066ab253db272e490a5.zip
cpython-729c31f5c3e8dcbff571e066ab253db272e490a5.tar.gz
cpython-729c31f5c3e8dcbff571e066ab253db272e490a5.tar.bz2
Reset internal buffers when seek() is called. This fixes SF bug #1156259.
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 01d8955..e6dba34 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -755,6 +755,21 @@ class BasicUnicodeTest(unittest.TestCase):
decodedresult += reader.read()
self.assertEqual(decodedresult, s, "%r != %r (encoding=%r)" % (decodedresult, s, encoding))
+ def test_seek(self):
+ # all codecs should be able to encode these
+ s = u"%s\n%s\n" % (100*u"abc123", 100*u"def456")
+ for encoding in all_unicode_encodings:
+ if encoding == "idna": # FIXME: See SF bug #1163178
+ continue
+ if encoding in broken_unicode_with_streams:
+ continue
+ reader = codecs.getreader(encoding)(StringIO.StringIO(s.encode(encoding)))
+ for t in xrange(5):
+ # Test that calling seek resets the internal codec state and buffers
+ reader.seek(0, 0)
+ line = reader.readline()
+ self.assertEqual(s[:len(line)], line)
+
class BasicStrTest(unittest.TestCase):
def test_basics(self):
s = "abc123"