Test partial recv when buffer is smaller than data.
(selenium_nodesock)
| 293 | |
| 294 | |
| 295 | def test_socket_send_recv_partial(selenium_nodesock): |
| 296 | """Test partial recv when buffer is smaller than data.""" |
| 297 | FULL_MESSAGE = b"A" * 1000 |
| 298 | |
| 299 | def handler(conn, _addr): |
| 300 | conn.recv(1024) |
| 301 | conn.sendall(FULL_MESSAGE) |
| 302 | |
| 303 | @run_in_pyodide |
| 304 | def run(selenium, host, port, full_message): |
| 305 | import socket |
| 306 | |
| 307 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 308 | s.connect((host, port)) |
| 309 | |
| 310 | s.sendall(b"start") |
| 311 | |
| 312 | received = b"" |
| 313 | while len(received) < len(full_message): |
| 314 | chunk = s.recv(100) |
| 315 | if not chunk: |
| 316 | break |
| 317 | received += chunk |
| 318 | |
| 319 | s.close() |
| 320 | return received.decode() |
| 321 | |
| 322 | with tcp_server(handler) as (host, port): |
| 323 | result = run(selenium_nodesock, host, port, FULL_MESSAGE) |
| 324 | assert len(result) == len(FULL_MESSAGE) |
| 325 | |
| 326 | |
| 327 | def test_socket_create_multiple(selenium_nodesock): |
nothing calls this directly
no test coverage detected
searching dependent graphs…