mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Issue #28683: Fix the tests that bind() a unix socket and raise PermissionError
on Android for a non-root user.
This commit is contained in:
parent
1351c31aa9
commit
e88ed05006
5 changed files with 33 additions and 8 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue