MCPcopy Index your code
hub / github.com/python/cpython / test_inplace_encoding_errors

Method test_inplace_encoding_errors

Lib/test/test_fileinput.py:328–336  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

326 self.assertEqual(f.read(), b'New line.')
327
328 def test_inplace_encoding_errors(self):
329 temp_file = self.writeTmp(b'Initial text \x88', mode='wb')
330 with FileInput(temp_file, inplace=True,
331 encoding="ascii", errors="replace") as fobj:
332 line = fobj.readline()
333 self.assertEqual(line, 'Initial text \ufffd')
334 print("New line \x88")
335 with open(temp_file, 'rb') as f:
336 self.assertEqual(f.read().rstrip(b'\r\n'), b'New line ?')
337
338 def test_file_hook_backward_compatibility(self):
339 def old_hook(filename, mode):

Callers

nothing calls this directly

Calls 7

FileInputClass · 0.90
writeTmpMethod · 0.80
openFunction · 0.50
readlineMethod · 0.45
assertEqualMethod · 0.45
rstripMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected