MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_modes

Method test_modes

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

Source from the content-addressed store, hash-verified

981 check('backslashreplace', ['\\x80abc'])
982
983 def test_modes(self):
984 with open(TESTFN, 'wb') as f:
985 # UTF-7 is a convenient, seldom used encoding
986 f.write(b'A\nB\r\nC\rD+IKw-')
987 self.addCleanup(safe_unlink, TESTFN)
988
989 def check(mode, expected_lines):
990 with FileInput(files=TESTFN, mode=mode,
991 openhook=hook_encoded('utf-7')) as fi:
992 lines = list(fi)
993 self.assertEqual(lines, expected_lines)
994
995 check('r', ['A\n', 'B\n', 'C\n', 'D\u20ac'])
996 with self.assertRaises(ValueError):
997 check('rb', ['A\n', 'B\r\n', 'C\r', 'D\u20ac'])
998
999
1000class MiscTest(unittest.TestCase):

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