fix mocking
This commit is contained in:
parent
f0df2fff21
commit
224ef60faf
|
@ -373,12 +373,12 @@ class APIConnection:
|
|||
aiohappyeyeballs.pop_addr_infos_interleave(addr_infos, interleave)
|
||||
|
||||
if sock is None:
|
||||
if isinstance(last_exception, OSError):
|
||||
raise SocketAPIError(
|
||||
f"Error connecting to {addr_infos}: {last_exception}"
|
||||
if isinstance(last_exception, asyncio_TimeoutError):
|
||||
raise TimeoutAPIError(
|
||||
f"Timeout while connecting to {addrs}"
|
||||
) from last_exception
|
||||
raise SocketAPIError(
|
||||
f"Timeout while connecting to {addr_infos}"
|
||||
f"Error connecting to {addrs}: {last_exception}"
|
||||
) from last_exception
|
||||
|
||||
self._socket = sock
|
||||
|
|
|
@ -39,12 +39,14 @@ def async_zeroconf():
|
|||
@pytest.fixture
|
||||
def resolve_host():
|
||||
with patch("aioesphomeapi.host_resolver.async_resolve_host") as func:
|
||||
func.return_value = AddrInfo(
|
||||
family=socket.AF_INET,
|
||||
type=socket.SOCK_STREAM,
|
||||
proto=socket.IPPROTO_TCP,
|
||||
sockaddr=IPv4Sockaddr("10.0.0.512", 6052),
|
||||
)
|
||||
func.return_value = [
|
||||
AddrInfo(
|
||||
family=socket.AF_INET,
|
||||
type=socket.SOCK_STREAM,
|
||||
proto=socket.IPPROTO_TCP,
|
||||
sockaddr=IPv4Sockaddr("10.0.0.512", 6052),
|
||||
)
|
||||
]
|
||||
yield func
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue