Skip to content

Commit

Permalink
Merge pull request #1328 from tjni/python3.11-brackets
Browse files Browse the repository at this point in the history
Remove brackets from IPv4 test hostnames
  • Loading branch information
pbiering authored Mar 1, 2024
2 parents d42e9ed + 110ec3a commit e6d4611
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions radicale/tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ def setup(self) -> None:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# Find available port
sock.bind(("127.0.0.1", 0))
self.sockfamily = socket.AF_INET
self.sockname = sock.getsockname()
self.configure({"server": {"hosts": "[%s]:%d" % self.sockname},
self.configure({"server": {"hosts": "%s:%d" % self.sockname},
# Enable debugging for new processes
"logging": {"level": "debug"}})
self.thread = threading.Thread(target=server.serve, args=(
Expand Down Expand Up @@ -105,8 +106,9 @@ def request(self, method: str, path: str, data: Optional[str] = None,
data_bytes = None
if data:
data_bytes = data.encode(encoding)
req_host = ("[%s]" % self.sockname[0]) if self.sockfamily == socket.AF_INET6 else self.sockname[0]
req = request.Request(
"%s://[%s]:%d%s" % (scheme, *self.sockname, path),
"%s://%s:%d%s" % (scheme, req_host, self.sockname[1], path),
data=data_bytes, headers=headers, method=method)
while True:
assert is_alive_fn()
Expand Down Expand Up @@ -161,6 +163,7 @@ def test_ipv6(self) -> None:
server.COMPAT_IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
# Find available port
sock.bind(("::1", 0))
self.sockfamily = socket.AF_INET6
self.sockname = sock.getsockname()[:2]
except OSError as e:
if e.errno in (errno.EADDRNOTAVAIL, errno.EAFNOSUPPORT,
Expand Down

0 comments on commit e6d4611

Please sign in to comment.