Test socket.getsockname() returns local address info.
(selenium_nodesock)
| 189 | |
| 190 | |
| 191 | def test_socket_getsockname(selenium_nodesock): |
| 192 | """Test socket.getsockname() returns local address info.""" |
| 193 | |
| 194 | def handler(conn, _addr): |
| 195 | conn.recv(1024) |
| 196 | conn.sendall(b"OK") |
| 197 | |
| 198 | @run_in_pyodide |
| 199 | def run(selenium, host, port): |
| 200 | import socket |
| 201 | |
| 202 | s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
| 203 | s.connect((host, port)) |
| 204 | |
| 205 | local = s.getsockname() |
| 206 | s.sendall(b"test") |
| 207 | s.recv(1024) |
| 208 | s.close() |
| 209 | return local |
| 210 | |
| 211 | with tcp_server(handler) as (host, port): |
| 212 | result = run(selenium_nodesock, host, port) |
| 213 | assert len(result) == 2 |
| 214 | assert isinstance(result[0], str) # IP |
| 215 | assert isinstance(result[1], int) # Port |
| 216 | |
| 217 | |
| 218 | def test_socket_connection_refused(selenium_nodesock): |
nothing calls this directly
no test coverage detected
searching dependent graphs…