diff -r 135e1a8144ec Lib/test/support/__init__.py --- a/Lib/test/support/__init__.py Mon Jan 09 11:21:37 2017 +0100 +++ b/Lib/test/support/__init__.py Mon Jan 09 16:36:41 2017 +0100 @@ -91,9 +91,10 @@ "requires_IEEE_754", "skip_unless_xattr", "requires_zlib", "anticipate_failure", "load_package_tests", "detect_api_mismatch", "check__all__", "requires_android_level", "requires_multiprocessing_queue", + "supported_operation", # sys "is_jython", "is_android", "check_impl_detail", "unix_shell", - "setswitchinterval", "android_not_root", + "setswitchinterval", # network "HOST", "IPV6_ENABLED", "find_unused_port", "bind_port", "open_urlresource", "bind_unix_socket", @@ -784,7 +785,6 @@ except AttributeError: # sys.getandroidapilevel() is only available on Android is_android = False -android_not_root = (is_android and os.geteuid() != 0) if sys.platform != 'win32': unix_shell = '/system/bin/sh' if is_android else '/bin/sh' @@ -1823,6 +1823,14 @@ msg = "requires a functioning shared semaphore implementation" return test if _have_mp_queue else unittest.skip(msg)(test) +@contextlib.contextmanager +def supported_operation(): + """Context manager to skip tests when the operation is not supported.""" + try: + yield + except PermissionError as e: + raise unittest.SkipTest(str(e)) + def _parse_guards(guards): # Returns a tuple ({platform_name: run_me}, default_value) if not guards: diff -r 135e1a8144ec Lib/test/test_socketserver.py --- a/Lib/test/test_socketserver.py Mon Jan 09 11:21:37 2017 +0100 +++ b/Lib/test/test_socketserver.py Mon Jan 09 16:36:41 2017 +0100 @@ -117,7 +117,9 @@ @reap_threads def run_server(self, svrcls, hdlrbase, testfunc): - server = self.make_server(self.pickaddr(svrcls.address_family), + # Issue 29184: cannot bind() a Unix socket on Android API 24. + with test.support.supported_operation(): + server = self.make_server(self.pickaddr(svrcls.address_family), svrcls, hdlrbase) # We had the OS pick a port, so pull the real address out of # the server.