(self)
| 991 | self.assertEqual(bytes(buffer), b"12345") |
| 992 | |
| 993 | def test_fspath_support(self): |
| 994 | def check_path_succeeds(path): |
| 995 | with self.open(path, "w", encoding="utf-8") as f: |
| 996 | f.write("egg\n") |
| 997 | |
| 998 | with self.open(path, "r", encoding="utf-8") as f: |
| 999 | self.assertEqual(f.read(), "egg\n") |
| 1000 | |
| 1001 | check_path_succeeds(FakePath(os_helper.TESTFN)) |
| 1002 | check_path_succeeds(FakePath(os.fsencode(os_helper.TESTFN))) |
| 1003 | |
| 1004 | with self.open(os_helper.TESTFN, "w", encoding="utf-8") as f: |
| 1005 | bad_path = FakePath(f.fileno()) |
| 1006 | with self.assertRaises(TypeError): |
| 1007 | self.open(bad_path, 'w', encoding="utf-8") |
| 1008 | |
| 1009 | bad_path = FakePath(None) |
| 1010 | with self.assertRaises(TypeError): |
| 1011 | self.open(bad_path, 'w', encoding="utf-8") |
| 1012 | |
| 1013 | bad_path = FakePath(FloatingPointError) |
| 1014 | with self.assertRaises(FloatingPointError): |
| 1015 | self.open(bad_path, 'w', encoding="utf-8") |
| 1016 | |
| 1017 | # ensure that refcounting is correct with some error conditions |
| 1018 | with self.assertRaisesRegex(ValueError, 'read/write/append mode'): |
| 1019 | self.open(FakePath(os_helper.TESTFN), 'rwxa', encoding="utf-8") |
| 1020 | |
| 1021 | def test_RawIOBase_readall(self): |
| 1022 | # Exercise the default unlimited RawIOBase.read() and readall() |
nothing calls this directly
no test coverage detected