Skip to content

Commit

Permalink
Fix test on MacOS (3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unrud committed Feb 20, 2020
1 parent ee984b4 commit f46a3e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions radicale/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,15 @@ def serve(configuration, shutdown_socket):
isinstance(e, socket.gaierror) and (
# Hostname does not exist or doesn't have
# address for address family
# macOS: IPv6 address for INET address family
e.errno == socket.EAI_NONAME or
# Address not for address family
e.errno == COMPAT_EAI_ADDRFAMILY) or
# Workaround for PyPy
str(e) == "address family mismatched" or
# Address family not available (e.g. IPv6 disabled)
# macOS: IPv4 address for INET6 address family with
# IPV6_V6ONLY set
e.errno == errno.EADDRNOTAVAIL)):
continue
raise RuntimeError("Failed to start server %r: %s" % (
Expand Down
5 changes: 3 additions & 2 deletions radicale/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ def test_bind_fail(self):
socket.IPV6_V6ONLY, 1)
with pytest.raises(OSError) as exc_info:
sock.bind((address, 0))
# See ``radicale.server.serve``
assert (isinstance(exc_info.value, socket.gaierror) and
exc_info.value.errno in (socket.EAI_NONAME,
server.COMPAT_EAI_ADDRFAMILY) or
# Workaround for PyPy
str(exc_info.value) == "address family mismatched")
str(exc_info.value) == "address family mismatched" or
exc_info.value.errno == errno.EADDRNOTAVAIL)

def test_ipv6(self):
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
Expand Down

0 comments on commit f46a3e3

Please sign in to comment.