diff options
| author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-22 02:12:28 (GMT) |
|---|---|---|
| committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-05-22 02:12:28 (GMT) |
| commit | f5a3eafaac77d897b702f0ae6dbb00b8449141f7 (patch) | |
| tree | d840f700e48ce572538d5e50e88a43d67b5c9dd1 /Lib/test/test_codecs.py | |
| parent | 9a4a01df756b7cde999214401e146600570b5cad (diff) | |
| download | cpython-f5a3eafaac77d897b702f0ae6dbb00b8449141f7.zip cpython-f5a3eafaac77d897b702f0ae6dbb00b8449141f7.tar.gz cpython-f5a3eafaac77d897b702f0ae6dbb00b8449141f7.tar.bz2 | |
Merged revisions 81459 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81459 | victor.stinner | 2010-05-22 04:11:07 +0200 (sam., 22 mai 2010) | 3 lines
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.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 7c3a30b..47b80f7 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -1488,6 +1488,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, @@ -1516,6 +1536,7 @@ def test_main(): BasicStrTest, CharmapTest, WithStmtTest, + BomTest, ) |
