patch 9.0.1165: tests using IPv6 sometimes fail
Problem: Tests using IPv6 sometimes fail.
Solution: Use getaddrinfo() and use try/catch. (James McCoy,
closes #11783)
diff --git a/src/testdir/test_channel.py b/src/testdir/test_channel.py
index 3ef0fde..35c34fc 100644
--- a/src/testdir/test_channel.py
+++ b/src/testdir/test_channel.py
@@ -259,7 +259,12 @@
print("Wait for it...")
time.sleep(0.5)
- server = server_class((host, port), ThreadedTCPRequestHandler)
+ addrs = socket.getaddrinfo(host, port, 0, 0, socket.IPPROTO_TCP)
+ # Each addr is a (family, type, proto, canonname, sockaddr) tuple
+ sockaddr = addrs[0][4]
+ server_class.address_family = addrs[0][0]
+
+ server = server_class(sockaddr[0:2], ThreadedTCPRequestHandler)
ip, port = server.server_address[0:2]
# Start a thread with the server. That thread will then start a new thread