mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
Fix issue1753: TextIOWrapper.write writes utf BOM for every string.
Patch by Erick Tryzelaar, with slight modifications by me.
This commit is contained in:
parent
52d168a995
commit
a38f73b1bb
2 changed files with 26 additions and 4 deletions
|
@ -765,6 +765,24 @@ class TextIOWrapperTest(unittest.TestCase):
|
|||
f.readline()
|
||||
f.tell()
|
||||
|
||||
def testEncodedWrites(self):
|
||||
data = "1234567890"
|
||||
tests = ("utf-16",
|
||||
"utf-16-le",
|
||||
"utf-16-be",
|
||||
"utf-32",
|
||||
"utf-32-le",
|
||||
"utf-32-be")
|
||||
for encoding in tests:
|
||||
buf = io.BytesIO()
|
||||
f = io.TextIOWrapper(buf, encoding=encoding)
|
||||
# Check if the BOM is written only once (see issue1753).
|
||||
f.write(data)
|
||||
f.write(data)
|
||||
f.seek(0)
|
||||
self.assertEquals(f.read(), data * 2)
|
||||
self.assertEquals(buf.getvalue(), (data * 2).encode(encoding))
|
||||
|
||||
def timingTest(self):
|
||||
timer = time.time
|
||||
enc = "utf8"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue