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

Method test_append_bom

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected