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

Method assert_sock_timeout

Lib/test/test_socket.py:5298–5313  ·  view source on GitHub ↗
(self, sock, timeout)

Source from the content-addressed store, hash-verified

5296 ThreadedTCPSocketTest.__init__(self, methodName=methodName)
5297
5298 def assert_sock_timeout(self, sock, timeout):
5299 self.assertEqual(self.serv.gettimeout(), timeout)
5300
5301 blocking = (timeout != 0.0)
5302 self.assertEqual(sock.getblocking(), blocking)
5303
5304 if fcntl is not None:
5305 # When a Python socket has a non-zero timeout, it's switched
5306 # internally to a non-blocking mode. Later, sock.sendall(),
5307 # sock.recv(), and other socket operations use a select() call and
5308 # handle EWOULDBLOCK/EGAIN on all socket operations. That's how
5309 # timeouts are enforced.
5310 fd_blocking = (timeout is None)
5311
5312 flag = fcntl.fcntl(sock, fcntl.F_GETFL, os.O_NONBLOCK)
5313 self.assertEqual(not bool(flag & os.O_NONBLOCK), fd_blocking)
5314
5315 def testSetBlocking(self):
5316 # Test setblocking() and settimeout() methods

Callers 2

testSetBlockingMethod · 0.95
testInitNonBlockingMethod · 0.95

Calls 3

getblockingMethod · 0.80
assertEqualMethod · 0.45
gettimeoutMethod · 0.45

Tested by

no test coverage detected