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

Method test_errors

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

Source from the content-addressed store, hash-verified

964 self.assertFalse(kwargs)
965
966 def test_errors(self):
967 with open(TESTFN, 'wb') as f:
968 f.write(b'\x80abc')
969 self.addCleanup(safe_unlink, TESTFN)
970
971 def check(errors, expected_lines):
972 with FileInput(files=TESTFN, mode='r',
973 openhook=hook_encoded('utf-8', errors=errors)) as fi:
974 lines = list(fi)
975 self.assertEqual(lines, expected_lines)
976
977 check('ignore', ['abc'])
978 with self.assertRaises(UnicodeDecodeError):
979 check('strict', ['abc'])
980 check('replace', ['\ufffdabc'])
981 check('backslashreplace', ['\\x80abc'])
982
983 def test_modes(self):
984 with open(TESTFN, 'wb') as f:

Callers

nothing calls this directly

Calls 5

addCleanupMethod · 0.80
checkFunction · 0.70
openFunction · 0.50
writeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected