MCPcopy Index your code
hub / github.com/python/cpython / skip_unless_bind_unix_socket

Function skip_unless_bind_unix_socket

Lib/test/support/socket_helper.py:148–168  ·  view source on GitHub ↗

Decorator for tests requiring a functional bind() for unix sockets.

(test)

Source from the content-addressed store, hash-verified

146
147_bind_nix_socket_error = None
148def skip_unless_bind_unix_socket(test):
149 """Decorator for tests requiring a functional bind() for unix sockets."""
150 if not hasattr(socket, 'AF_UNIX'):
151 return unittest.skip('No UNIX Sockets')(test)
152 global _bind_nix_socket_error
153 if _bind_nix_socket_error is None:
154 from .os_helper import TESTFN, unlink
155 path = TESTFN + "can_bind_unix_socket"
156 with socket.socket(socket.AF_UNIX) as sock:
157 try:
158 sock.bind(path)
159 _bind_nix_socket_error = False
160 except OSError as e:
161 _bind_nix_socket_error = e
162 finally:
163 unlink(path)
164 if _bind_nix_socket_error:
165 msg = 'Requires a functional unix bind(): %s' % _bind_nix_socket_error
166 return unittest.skip(msg)(test)
167 else:
168 return test
169
170
171def get_socket_conn_refused_errs():

Callers

nothing calls this directly

Calls 4

unlinkFunction · 0.85
skipMethod · 0.80
socketMethod · 0.80
bindMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…