(self)
| 2093 | |
| 2094 | @unittest.skipUnless(hasattr(os, 'sendfile'), 'test needs os.sendfile()') |
| 2095 | def test__sendfile_use_sendfile(self): |
| 2096 | class File: |
| 2097 | def __init__(self, fd): |
| 2098 | self.fd = fd |
| 2099 | |
| 2100 | def fileno(self): |
| 2101 | return self.fd |
| 2102 | with socket.socket() as sock: |
| 2103 | fd = os.open(os.curdir, os.O_RDONLY) |
| 2104 | os.close(fd) |
| 2105 | with self.assertRaises(socket._GiveupOnSendfile): |
| 2106 | sock._sendfile_use_sendfile(File(fd)) |
| 2107 | with self.assertRaises(OverflowError): |
| 2108 | sock._sendfile_use_sendfile(File(2**1000)) |
| 2109 | with self.assertRaises(TypeError): |
| 2110 | sock._sendfile_use_sendfile(File(None)) |
| 2111 | |
| 2112 | def _test_socket_fileno(self, s, family, stype): |
| 2113 | self.assertEqual(s.family, family) |
nothing calls this directly
no test coverage detected