From 9f7c4b75a61e870b41556895c35e04997ac8b7fc Mon Sep 17 00:00:00 2001 From: Matthew Wardrop Date: Fri, 31 Mar 2023 18:14:40 -0700 Subject: [PATCH] fix: Fix resolving named hosts. --- pytest_socket.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pytest_socket.py b/pytest_socket.py index 06bdc1c..90d8a2b 100644 --- a/pytest_socket.py +++ b/pytest_socket.py @@ -226,6 +226,8 @@ def socket_allow_hosts(allowed=None, allow_unix_socket=False): def guarded_connect(inst, *args): host = host_from_connect_args(args) + if host and not is_ipaddress(host): + host = resolve_hostname(host) if host in allowed_hosts or ( _is_unix_socket(inst.family) and allow_unix_socket ):