summaryrefslogtreecommitdiff
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-05-22 02:11:07 +0000
committerVictor Stinner <victor.stinner@haypocalc.com>2010-05-22 02:11:07 +0000
commit262be5e70bd75520d3d95a19ceda3eb97bd7045c (patch)
treec0e96ea7b54c66fa06c0a66cb747beec67677511 /Lib/test/test_codecs.py
parentd6703b5e38baac6b85c1c2cf9311e11e4916984b (diff)
downloadcpython-git-262be5e70bd75520d3d95a19ceda3eb97bd7045c.tar.gz
Issue #6268: Fix seek() method of codecs.open(), don't read the BOM twice
after seek(0)
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index f8563f61ae..306a3b2ee6 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -1496,6 +1496,26 @@ class WithStmtTest(unittest.TestCase):
self.assertEquals(srw.read(), u"\xfc")
+class BomTest(unittest.TestCase):
+ def test_seek0(self):
+ data = "1234567890"
+ tests = ("utf-16",
+ "utf-16-le",
+ "utf-16-be",
+ "utf-32",
+ "utf-32-le",
+ "utf-32-be")
+ for encoding in tests:
+ with codecs.open('foo', 'wt+', encoding=encoding) as f:
+ # Check if the BOM is written only once
+ f.write(data)
+ f.write(data)
+ f.seek(0)
+ self.assertEquals(f.read(), data * 2)
+ f.seek(0)
+ self.assertEquals(f.read(), data * 2)
+
+
def test_main():
test_support.run_unittest(
UTF32Test,
@@ -1524,6 +1544,7 @@ def test_main():
BasicStrTest,
CharmapTest,
WithStmtTest,
+ BomTest,
)