diff options
author | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-12-14 10:52:28 (GMT) |
---|---|---|
committer | Xavier de Gaye <xdegaye@users.sourceforge.net> | 2016-12-14 10:52:28 (GMT) |
commit | e88ed05006d4eef73e550149efa5ec11c6336dcc (patch) | |
tree | fcc6a625175d8475fb86f7852da849d88070c3a1 /Lib/test/test_socket.py | |
parent | 1351c31aa9651b278d7ef8ec79af3b646a520235 (diff) | |
download | cpython-e88ed05006d4eef73e550149efa5ec11c6336dcc.zip cpython-e88ed05006d4eef73e550149efa5ec11c6336dcc.tar.gz cpython-e88ed05006d4eef73e550149efa5ec11c6336dcc.tar.bz2 |
Issue #28683: Fix the tests that bind() a unix socket and raise PermissionError
on Android for a non-root user.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r-- | Lib/test/test_socket.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 59564c9..6b29e18 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -278,8 +278,14 @@ class ThreadableTest: def clientRun(self, test_func): self.server_ready.wait() - self.clientSetUp() - self.client_ready.set() + try: + self.clientSetUp() + except BaseException as e: + self.queue.put(e) + self.clientTearDown() + return + finally: + self.client_ready.set() if self.server_crashed: self.clientTearDown() return @@ -520,8 +526,11 @@ class ConnectedStreamTestMixin(SocketListeningTestMixin, self.serv_conn = self.cli def clientTearDown(self): - self.serv_conn.close() - self.serv_conn = None + try: + self.serv_conn.close() + self.serv_conn = None + except AttributeError: + pass super().clientTearDown() @@ -540,7 +549,7 @@ class UnixSocketTestBase(SocketTestBase): def bindSock(self, sock): path = tempfile.mktemp(dir=self.dir_path) - sock.bind(path) + support.bind_unix_socket(sock, path) self.addCleanup(support.unlink, path) class UnixStreamBase(UnixSocketTestBase): @@ -4631,7 +4640,7 @@ class TestUnixDomain(unittest.TestCase): def bind(self, sock, path): # Bind the socket try: - sock.bind(path) + support.bind_unix_socket(sock, path) except OSError as e: if str(e) == "AF_UNIX path too long": self.skipTest( |