()
| 286 | |
| 287 | |
| 288 | async def test_init() -> None: |
| 289 | fn() |
| 290 | with pytest.raises( |
| 291 | NotImplementedError, |
| 292 | match=re.escape( |
| 293 | f"FakeNet doesn't (yet) support type={trio.socket.SOCK_STREAM}", |
| 294 | ), |
| 295 | ): |
| 296 | s1 = trio.socket.socket() |
| 297 | |
| 298 | # getsockname on unbound ipv4 socket |
| 299 | s1 = trio.socket.socket(type=trio.socket.SOCK_DGRAM) |
| 300 | assert s1.getsockname() == ("0.0.0.0", 0) |
| 301 | |
| 302 | # getsockname on bound ipv4 socket |
| 303 | await s1.bind(("0.0.0.0", 0)) |
| 304 | ip, port = s1.getsockname() |
| 305 | assert ip == "127.0.0.1" |
| 306 | assert port != 0 |
| 307 | |
| 308 | # getsockname on unbound ipv6 socket |
| 309 | s2 = trio.socket.socket(family=socket.AF_INET6, type=socket.SOCK_DGRAM) |
| 310 | assert s2.getsockname() == ("::", 0) |
| 311 | |
| 312 | # getsockname on bound ipv6 socket |
| 313 | await s2.bind(("::", 0)) |
| 314 | ip, port, *_ = s2.getsockname() |
| 315 | assert ip == "::1" |
| 316 | assert port != 0 |
| 317 | assert _ == [0, 0] |
nothing calls this directly
no test coverage detected
searching dependent graphs…