| 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): |