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

Method test_inplace_binary_write_mode

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

Source from the content-addressed store, hash-verified

316 self.assertEqual(fi.readline(), b'')
317
318 def test_inplace_binary_write_mode(self):
319 temp_file = self.writeTmp(b'Initial text.', mode='wb')
320 with FileInput(temp_file, mode='rb', inplace=True) as fobj:
321 line = fobj.readline()
322 self.assertEqual(line, b'Initial text.')
323 # print() cannot be used with files opened in binary mode.
324 sys.stdout.write(b'New line.')
325 with open(temp_file, 'rb') as f:
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')

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected