Skip to content

Commit b1c73d7

Browse files
committed
re-apply test.support patches
1 parent 71fcc7c commit b1c73d7

File tree

1 file changed

+48
-21
lines changed

1 file changed

+48
-21
lines changed

graalpython/lib-python/3/test/support/__init__.py

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ def wrapper(*args, **kw):
630630
HOSTv6 = "::1"
631631

632632

633-
def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
633+
# TODO: revert me once socket is implemented (GR-9140)
634+
# def find_unused_port(family=socket.AF_INET, socktype=socket.SOCK_STREAM):
635+
def find_unused_port(family, socktype):
634636
"""Returns an unused port that should be suitable for binding. This is
635637
achieved by creating a temporary socket with the same family and type as
636638
the 'sock' parameter (default is AF_INET, SOCK_STREAM), and binding it to
@@ -729,22 +731,33 @@ def bind_port(sock, host=HOST):
729731
port = sock.getsockname()[1]
730732
return port
731733

732-
def _is_ipv6_enabled():
733-
"""Check whether IPv6 is enabled on this host."""
734-
if socket.has_ipv6:
735-
sock = None
736-
try:
737-
sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
738-
sock.bind((HOSTv6, 0))
739-
return True
740-
except OSError:
741-
pass
742-
finally:
743-
if sock:
744-
sock.close()
745-
return False
746-
747-
IPV6_ENABLED = _is_ipv6_enabled()
734+
def bind_unix_socket(sock, addr):
735+
"""Bind a unix socket, raising SkipTest if PermissionError is raised."""
736+
assert sock.family == socket.AF_UNIX
737+
try:
738+
sock.bind(addr)
739+
except PermissionError:
740+
sock.close()
741+
raise unittest.SkipTest('cannot bind AF_UNIX sockets')
742+
743+
# TODO: reenable me once socket is implemented (GR-9140)
744+
# def _is_ipv6_enabled():
745+
# """Check whether IPv6 is enabled on this host."""
746+
# if socket.has_ipv6:
747+
# sock = None
748+
# try:
749+
# sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
750+
# sock.bind((HOSTv6, 0))
751+
# return True
752+
# except OSError:
753+
# pass
754+
# finally:
755+
# if sock:
756+
# sock.close()
757+
# return False
758+
#
759+
# IPV6_ENABLED = _is_ipv6_enabled()
760+
IPV6_ENABLED = False
748761

749762
def system_must_validate_cert(f):
750763
"""Skip the test on TLS certificate validation failures."""
@@ -788,6 +801,17 @@ def dec(*args, **kwargs):
788801

789802
is_jython = sys.platform.startswith('java')
790803

804+
# TODO: reenable me once sysconfig is properly implemented (GR-9150)
805+
# _ANDROID_API_LEVEL = sysconfig.get_config_var('ANDROID_API_LEVEL')
806+
# is_android = (_ANDROID_API_LEVEL is not None and _ANDROID_API_LEVEL > 0)
807+
is_android = False
808+
android_not_root = (is_android and os.geteuid() != 0)
809+
810+
if sys.platform != 'win32':
811+
unix_shell = '/system/bin/sh' if is_android else '/bin/sh'
812+
else:
813+
unix_shell = None
814+
791815
# Filename used for testing
792816
if os.name == 'java':
793817
# Jython disallows @ in module names
@@ -1924,9 +1948,12 @@ def case_pred(test):
19241948
def _check_docstrings():
19251949
"""Just used to check if docstrings are enabled"""
19261950

1927-
MISSING_C_DOCSTRINGS = (check_impl_detail() and
1928-
sys.platform != 'win32' and
1929-
not sysconfig.get_config_var('WITH_DOC_STRINGS'))
1951+
1952+
#TODO reenable me once platform and sysconfig are implemented/supported
1953+
# MISSING_C_DOCSTRINGS = (check_impl_detail() and
1954+
# sys.platform != 'win32' and
1955+
# not sysconfig.get_config_var('WITH_DOC_STRINGS'))
1956+
MISSING_C_DOCSTRINGS = False
19301957

19311958
HAVE_DOCSTRINGS = (_check_docstrings.__doc__ is not None and
19321959
not MISSING_C_DOCSTRINGS)
@@ -2264,7 +2291,7 @@ def can_xattr():
22642291
os.setxattr(fp.fileno(), b"user.test", b"")
22652292
# Kernels < 2.6.39 don't respect setxattr flags.
22662293
kernel_version = platform.release()
2267-
m = re.match("2.6.(\d{1,2})", kernel_version)
2294+
m = re.match(r"2.6.(\d{1,2})", kernel_version)
22682295
can = m is None or int(m.group(1)) >= 39
22692296
except OSError:
22702297
can = False

0 commit comments

Comments
 (0)