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

Method test__sendfile_use_sendfile

Lib/test/test_socket.py:2095–2110  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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)

Callers

nothing calls this directly

Calls 6

FileClass · 0.85
socketMethod · 0.80
openMethod · 0.45
closeMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected