summaryrefslogtreecommitdiffstats
path: root/Lib/test/support
diff options
context:
space:
mode:
authorXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-14 10:54:49 (GMT)
committerXavier de Gaye <xdegaye@users.sourceforge.net>2016-12-14 10:54:49 (GMT)
commit69598527c7b8c538d75ec1b69c54f317dee0c47a (patch)
tree9b728069895979b2740c4ca8e05682d27375f005 /Lib/test/support
parente43edaad7e2ba2132662267745c73754fc3b2d77 (diff)
parente88ed05006d4eef73e550149efa5ec11c6336dcc (diff)
downloadcpython-69598527c7b8c538d75ec1b69c54f317dee0c47a.zip
cpython-69598527c7b8c538d75ec1b69c54f317dee0c47a.tar.gz
cpython-69598527c7b8c538d75ec1b69c54f317dee0c47a.tar.bz2
Issue #28683: Merge 3.6.
Diffstat (limited to 'Lib/test/support')
-rw-r--r--Lib/test/support/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py
index bed76eb..345e16d 100644
--- a/Lib/test/support/__init__.py
+++ b/Lib/test/support/__init__.py
@@ -96,6 +96,7 @@ __all__ = [
"setswitchinterval", "android_not_root",
# network
"HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource",
+ "bind_unix_socket",
# processes
'temp_umask', "reap_children",
# logging
@@ -708,6 +709,15 @@ def bind_port(sock, host=HOST):
port = sock.getsockname()[1]
return port
+def bind_unix_socket(sock, addr):
+ """Bind a unix socket, raising SkipTest if PermissionError is raised."""
+ assert sock.family == socket.AF_UNIX
+ try:
+ sock.bind(addr)
+ except PermissionError:
+ sock.close()
+ raise unittest.SkipTest('cannot bind AF_UNIX sockets')
+
def _is_ipv6_enabled():
"""Check whether IPv6 is enabled on this host."""
if socket.has_ipv6: