MCPcopy Index your code
hub / github.com/pyodide/pyodide / test_socket_send_after_remote_close

Function test_socket_send_after_remote_close

src/tests/test_python_socket.py:395–421  ·  view source on GitHub ↗

Test that sending data after the remote side closes raises an error.

(selenium_nodesock)

Source from the content-addressed store, hash-verified

393
394
395def test_socket_send_after_remote_close(selenium_nodesock):
396 """Test that sending data after the remote side closes raises an error."""
397
398 def handler(conn, _addr):
399 conn.close()
400
401 @run_in_pyodide(packages=["pytest"])
402 def run(selenium, host, port):
403 import socket
404 import time
405
406 import pytest
407
408 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
409 s.connect((host, port))
410
411 # Give time for the FIN to arrive
412 time.sleep(0.5)
413
414 with pytest.raises(OSError):
415 # Send enough data to trigger the error
416 for _ in range(10):
417 s.sendall(b"X" * 4096)
418 time.sleep(0.05)
419
420 with tcp_server(handler) as (host, port):
421 run(selenium_nodesock, host, port)
422
423
424def test_socket_makefile(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…