| 719 | f.close() |
| 720 | |
| 721 | def test_encoded_writes(self): |
| 722 | data = "1234567890" |
| 723 | tests = ("utf-16", |
| 724 | "utf-16-le", |
| 725 | "utf-16-be", |
| 726 | "utf-32", |
| 727 | "utf-32-le", |
| 728 | "utf-32-be") |
| 729 | for encoding in tests: |
| 730 | buf = self.BytesIO() |
| 731 | f = self.TextIOWrapper(buf, encoding=encoding) |
| 732 | # Check if the BOM is written only once (see issue1753). |
| 733 | f.write(data) |
| 734 | f.write(data) |
| 735 | f.seek(0) |
| 736 | self.assertEqual(f.read(), data * 2) |
| 737 | f.seek(0) |
| 738 | self.assertEqual(f.read(), data * 2) |
| 739 | self.assertEqual(buf.getvalue(), (data * 2).encode(encoding)) |
| 740 | |
| 741 | def test_unreadable(self): |
| 742 | class UnReadable(self.BytesIO): |