Test that socket.fileno() returns a valid file descriptor.
(selenium_nodesock)
| 263 | |
| 264 | |
| 265 | def 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 | |
| 295 | def test_socket_send_recv_partial(selenium_nodesock): |
nothing calls this directly
no test coverage detected
searching dependent graphs…