| 857 | self.assertEqual(buffer.seekable(), txt.seekable()) |
| 858 | |
| 859 | def test_append_bom(self): |
| 860 | # The BOM is not written again when appending to a non-empty file |
| 861 | filename = os_helper.TESTFN |
| 862 | for charset in ('utf-8-sig', 'utf-16', 'utf-32'): |
| 863 | with self.open(filename, 'w', encoding=charset) as f: |
| 864 | f.write('aaa') |
| 865 | pos = f.tell() |
| 866 | with self.open(filename, 'rb') as f: |
| 867 | self.assertEqual(f.read(), 'aaa'.encode(charset)) |
| 868 | |
| 869 | with self.open(filename, 'a', encoding=charset) as f: |
| 870 | f.write('xxx') |
| 871 | with self.open(filename, 'rb') as f: |
| 872 | self.assertEqual(f.read(), 'aaaxxx'.encode(charset)) |
| 873 | |
| 874 | def test_seek_bom(self): |
| 875 | # Same test, but when seeking manually |