(self)
| 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 | |
| 1000 | class MiscTest(unittest.TestCase): |
nothing calls this directly
no test coverage detected