| 872 | self.assertEqual(f.read(), 'aaaxxx'.encode(charset)) |
| 873 | |
| 874 | def test_seek_bom(self): |
| 875 | # Same test, but when seeking manually |
| 876 | filename = os_helper.TESTFN |
| 877 | for charset in ('utf-8-sig', 'utf-16', 'utf-32'): |
| 878 | with self.open(filename, 'w', encoding=charset) as f: |
| 879 | f.write('aaa') |
| 880 | pos = f.tell() |
| 881 | with self.open(filename, 'r+', encoding=charset) as f: |
| 882 | f.seek(pos) |
| 883 | f.write('zzz') |
| 884 | f.seek(0) |
| 885 | f.write('bbb') |
| 886 | with self.open(filename, 'rb') as f: |
| 887 | self.assertEqual(f.read(), 'bbbzzz'.encode(charset)) |
| 888 | |
| 889 | def test_seek_append_bom(self): |
| 890 | # Same test, but first seek to the start and then to the end |