Skip to content

Commit

Permalink
test the e.errno != socket.EAI_NONAME branch in tcp._getaddrinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed May 24, 2023
1 parent aca710d commit da1b60a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions distributed/comm/tests/test_tcp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import annotations

import socket

import pytest

from distributed.comm.tcp import TCPConnector


# cover the `if e.errno != socket.EAI_NONAME` branch of tcp._getaddrinfo
def test_getaddrinfo_invalid_af():
with pytest.raises(socket.gaierror) as exc_info:
(
TCPConnector()
.client.connect(host="::1", port=1234, af=socket.AF_INET)
.__await__()
# test that getaddrinfo is called without yielding to the event loop
.send(None)
)
assert exc_info.value.errno == socket.EAI_ADDRFAMILY

0 comments on commit da1b60a

Please sign in to comment.