MCPcopy
hub / github.com/pyodide/pyodide / test_socket_fileno

Function test_socket_fileno

src/tests/test_python_socket.py:265–292  ·  view source on GitHub ↗

Test that socket.fileno() returns a valid file descriptor.

(selenium_nodesock)

Source from the content-addressed store, hash-verified

263
264
265def test_socket_fileno(selenium_nodesock):
266 """Test that socket.fileno() returns a valid file descriptor."""
267
268 def handler(conn, _addr):
269 conn.recv(1024)
270 conn.sendall(b"OK")
271
272 @run_in_pyodide
273 def run(selenium, host, port):
274 import socket
275
276 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
277 fd_before = s.fileno()
278
279 s.connect((host, port))
280 fd_after = s.fileno()
281
282 s.sendall(b"test")
283 s.recv(1024)
284 s.close()
285
286 return (fd_before, fd_after)
287
288 with tcp_server(handler) as (host, port):
289 result = run(selenium_nodesock, host, port)
290 assert isinstance(result[0], int) and result[0] > 0
291 assert isinstance(result[1], int) and result[1] > 0
292 assert result[0] == result[1]
293
294
295def test_socket_send_recv_partial(selenium_nodesock):

Callers

nothing calls this directly

Calls 2

tcp_serverFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…