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

Function test_socket_makefile

src/tests/test_python_socket.py:424–446  ·  view source on GitHub ↗

Test socket.makefile() with line-based I/O.

(selenium_nodesock)

Source from the content-addressed store, hash-verified

422
423
424def test_socket_makefile(selenium_nodesock):
425 """Test socket.makefile() with line-based I/O."""
426
427 def handler(conn, _addr):
428 conn.sendall(b"line1\nline2\nline3\n")
429 conn.close()
430
431 @run_in_pyodide
432 def run(selenium, host, port):
433 import socket
434
435 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
436 s.connect((host, port))
437
438 f = s.makefile("r")
439 lines = f.readlines()
440 f.close()
441 s.close()
442 return [l.strip() for l in lines]
443
444 with tcp_server(handler) as (host, port):
445 result = run(selenium_nodesock, host, port)
446 assert result == ["line1", "line2", "line3"]
447
448
449def test_socket_asyncio_concurrent(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…