Test that recv returns b'' after server closes and all data is consumed.
(selenium_nodesock)
| 362 | |
| 363 | |
| 364 | def test_socket_recv_eof(selenium_nodesock): |
| 365 | """Test that recv returns b'' after server closes and all data is consumed.""" |
| 366 | |
| 367 | def handler(conn, _addr): |
| 368 | conn.sendall(b"goodbye") |
| 369 | conn.close() |
| 370 | |
| 371 | @run_in_pyodide |
| 372 | def run(selenium, host, port): |
| 373 | import socket |
| 374 | import time |
| 375 | |
| 376 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 377 | s.connect((host, port)) |
| 378 | |
| 379 | data = s.recv(1024) |
| 380 | |
| 381 | # Give time for the FIN to arrive |
| 382 | time.sleep(1.0) |
| 383 | |
| 384 | eof = s.recv(1024) |
| 385 | |
| 386 | s.close() |
| 387 | return (data.decode(), len(eof)) |
| 388 | |
| 389 | with tcp_server(handler) as (host, port): |
| 390 | result = run(selenium_nodesock, host, port) |
| 391 | assert result[0] == "goodbye" |
| 392 | assert result[1] == 0 |
| 393 | |
| 394 | |
| 395 | def test_socket_send_after_remote_close(selenium_nodesock): |
nothing calls this directly
no test coverage detected
searching dependent graphs…