diff -r 878f91b4ad19 Lib/asyncio/test_utils.py --- a/Lib/asyncio/test_utils.py Thu Nov 17 09:22:43 2016 +0100 +++ b/Lib/asyncio/test_utils.py Thu Nov 17 11:59:57 2016 +0100 @@ -220,9 +220,12 @@ @contextlib.contextmanager def run_test_unix_server(*, use_ssl=False): with unix_socket_path() as path: - yield from _run_test_server(address=path, use_ssl=use_ssl, + try: + yield from _run_test_server(address=path, use_ssl=use_ssl, server_cls=SilentUnixWSGIServer, server_ssl_cls=UnixSSLWSGIServer) + except PermissionError: + raise unittest.SkipTest('cannot bind AF_UNIX sockets') @contextlib.contextmanager diff -r 878f91b4ad19 Lib/test/test_asyncio/test_events.py --- a/Lib/test/test_asyncio/test_events.py Thu Nov 17 09:22:43 2016 +0100 +++ b/Lib/test/test_asyncio/test_events.py Thu Nov 17 11:59:57 2016 +0100 @@ -931,7 +931,10 @@ self.addCleanup(lambda: os.path.exists(path) and os.unlink(path)) f = self.loop.create_unix_server(factory, path, **kwargs) - server = self.loop.run_until_complete(f) + try: + server = self.loop.run_until_complete(f) + except PermissionError: + self.skipTest('cannot bind AF_UNIX sockets') return server, path diff -r 878f91b4ad19 Lib/test/test_asyncio/test_streams.py --- a/Lib/test/test_asyncio/test_streams.py Thu Nov 17 09:22:43 2016 +0100 +++ b/Lib/test/test_asyncio/test_streams.py Thu Nov 17 11:59:57 2016 +0100 @@ -651,10 +651,13 @@ client_writer.close() def start(self): - self.server = self.loop.run_until_complete( - asyncio.start_unix_server(self.handle_client, + try: + self.server = self.loop.run_until_complete( + asyncio.start_unix_server(self.handle_client, path=self.path, loop=self.loop)) + except PermissionError: + raise unittest.SkipTest('cannot bind AF_UNIX sockets') def handle_client_callback(self, client_reader, client_writer): self.loop.create_task(self.handle_client(client_reader, diff -r 878f91b4ad19 Lib/test/test_asyncio/test_unix_events.py --- a/Lib/test/test_asyncio/test_unix_events.py Thu Nov 17 09:22:43 2016 +0100 +++ b/Lib/test/test_asyncio/test_unix_events.py Thu Nov 17 11:59:57 2016 +0100 @@ -243,7 +243,11 @@ def test_create_unix_server_existing_path_sock(self): with test_utils.unix_socket_path() as path: sock = socket.socket(socket.AF_UNIX) - sock.bind(path) + try: + sock.bind(path) + except PermissionError: + sock.close() + self.skipTest('cannot bind AF_UNIX sockets') sock.listen(1) sock.close() @@ -257,7 +261,10 @@ with test_utils.unix_socket_path() as path: path = pathlib.Path(path) srv_coro = self.loop.create_unix_server(lambda: None, path) - srv = self.loop.run_until_complete(srv_coro) + try: + srv = self.loop.run_until_complete(srv_coro) + except PermissionError: + self.skipTest('cannot bind AF_UNIX sockets') srv.close() self.loop.run_until_complete(srv.wait_closed()) @@ -308,14 +315,18 @@ fn = file.name try: with sock: - sock.bind(fn) + try: + sock.bind(fn) + except PermissionError: + self.skipTest('cannot bind AF_UNIX sockets') coro = self.loop.create_unix_server(lambda: None, path=None, sock=sock) srv = self.loop.run_until_complete(coro) srv.close() self.loop.run_until_complete(srv.wait_closed()) finally: - os.unlink(fn) + if os.path.exists(fn): + os.unlink(fn) def test_create_unix_connection_path_inetsock(self): sock = socket.socket()