From 227577d6c37c4066513c5027eb6c9d96206079a1 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..821a556 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 not is_ipaddress(host): + host = resolve_hostname(host) if host in allowed_hosts or ( _is_unix_socket(inst.family) and allow_unix_socket ):