summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_io.py
diff options
context:
space:
mode:
authorAlexandre Vassalotti <alexandre@peadrop.com>2008-01-07 18:30:48 (GMT)
committerAlexandre Vassalotti <alexandre@peadrop.com>2008-01-07 18:30:48 (GMT)
commita38f73b1bb327ceb1aad3a3001255ab81da91c22 (patch)
treee1bc52230da9265f8b809b049f2499819047942f /Lib/test/test_io.py
parent52d168a9950cc0933b6f650e5fdebfad13347e88 (diff)
downloadcpython-a38f73b1bb327ceb1aad3a3001255ab81da91c22.zip
cpython-a38f73b1bb327ceb1aad3a3001255ab81da91c22.tar.gz
cpython-a38f73b1bb327ceb1aad3a3001255ab81da91c22.tar.bz2
Fix issue1753: TextIOWrapper.write writes utf BOM for every string.
Patch by Erick Tryzelaar, with slight modifications by me.
Diffstat (limited to 'Lib/test/test_io.py')
-rw-r--r--Lib/test/test_io.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
index 33b32e0..4963416 100644
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -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"