| 3379 | f.close() |
| 3380 | |
| 3381 | def test_encoded_writes(self): |
| 3382 | data = "1234567890" |
| 3383 | tests = ("utf-16", |
| 3384 | "utf-16-le", |
| 3385 | "utf-16-be", |
| 3386 | "utf-32", |
| 3387 | "utf-32-le", |
| 3388 | "utf-32-be") |
| 3389 | for encoding in tests: |
| 3390 | buf = self.BytesIO() |
| 3391 | f = self.TextIOWrapper(buf, encoding=encoding) |
| 3392 | # Check if the BOM is written only once (see issue1753). |
| 3393 | f.write(data) |
| 3394 | f.write(data) |
| 3395 | f.seek(0) |
| 3396 | self.assertEqual(f.read(), data * 2) |
| 3397 | f.seek(0) |
| 3398 | self.assertEqual(f.read(), data * 2) |
| 3399 | self.assertEqual(buf.getvalue(), (data * 2).encode(encoding)) |
| 3400 | |
| 3401 | def test_unreadable(self): |
| 3402 | class UnReadable(self.BytesIO): |