Bind a unix socket, raising SkipTest if PermissionError is raised.
(sock, addr)
| 118 | return port |
| 119 | |
| 120 | def bind_unix_socket(sock, addr): |
| 121 | """Bind a unix socket, raising SkipTest if PermissionError is raised.""" |
| 122 | assert sock.family == socket.AF_UNIX |
| 123 | try: |
| 124 | sock.bind(addr) |
| 125 | except PermissionError: |
| 126 | sock.close() |
| 127 | raise unittest.SkipTest('cannot bind AF_UNIX sockets') |
| 128 | |
| 129 | def _is_ipv6_enabled(): |
| 130 | """Check whether IPv6 is enabled on this host.""" |