Fix test on MacOS (3)

This commit is contained in:
Unrud 2020-02-20 11:27:26 +01:00
parent ee984b49d4
commit f46a3e3d24
2 changed files with 6 additions and 2 deletions

View File

@ -223,12 +223,15 @@ def serve(configuration, shutdown_socket):
isinstance(e, socket.gaierror) and ( isinstance(e, socket.gaierror) and (
# Hostname does not exist or doesn't have # Hostname does not exist or doesn't have
# address for address family # address for address family
# macOS: IPv6 address for INET address family
e.errno == socket.EAI_NONAME or e.errno == socket.EAI_NONAME or
# Address not for address family # Address not for address family
e.errno == COMPAT_EAI_ADDRFAMILY) or e.errno == COMPAT_EAI_ADDRFAMILY) or
# Workaround for PyPy # Workaround for PyPy
str(e) == "address family mismatched" or str(e) == "address family mismatched" or
# Address family not available (e.g. IPv6 disabled) # Address family not available (e.g. IPv6 disabled)
# macOS: IPv4 address for INET6 address family with
# IPV6_V6ONLY set
e.errno == errno.EADDRNOTAVAIL)): e.errno == errno.EADDRNOTAVAIL)):
continue continue
raise RuntimeError("Failed to start server %r: %s" % ( raise RuntimeError("Failed to start server %r: %s" % (

View File

@ -126,11 +126,12 @@ class TestBaseServerRequests(BaseTest):
socket.IPV6_V6ONLY, 1) socket.IPV6_V6ONLY, 1)
with pytest.raises(OSError) as exc_info: with pytest.raises(OSError) as exc_info:
sock.bind((address, 0)) sock.bind((address, 0))
# See ``radicale.server.serve``
assert (isinstance(exc_info.value, socket.gaierror) and assert (isinstance(exc_info.value, socket.gaierror) and
exc_info.value.errno in (socket.EAI_NONAME, exc_info.value.errno in (socket.EAI_NONAME,
server.COMPAT_EAI_ADDRFAMILY) or server.COMPAT_EAI_ADDRFAMILY) or
# Workaround for PyPy str(exc_info.value) == "address family mismatched" or
str(exc_info.value) == "address family mismatched") exc_info.value.errno == errno.EADDRNOTAVAIL)
def test_ipv6(self): def test_ipv6(self):
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock: with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock: