MCPcopy Create free account
hub / github.com/python/cpython / test_seek_bom

Method test_seek_bom

Lib/test/test_io/test_textio.py:874–887  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

openMethod · 0.45
writeMethod · 0.45
tellMethod · 0.45
seekMethod · 0.45
assertEqualMethod · 0.45
readMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected