mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-28684: asyncio tests handle PermissionError raised on binding unix sockets (GH-4503)
The test.support.skip_unless_bind_unix_socket() decorator is used to skip asyncio tests that fail because the platform lacks a functional bind() function for unix domain sockets (as it is the case for non root users on the recent Android versions that run now SELinux in enforcing mode).
This commit is contained in:
parent
19fb134185
commit
0f86cd38f4
5 changed files with 45 additions and 11 deletions
|
@ -9,6 +9,7 @@ import sys
|
|||
import threading
|
||||
import unittest
|
||||
from unittest import mock
|
||||
from test import support
|
||||
try:
|
||||
import ssl
|
||||
except ImportError:
|
||||
|
@ -57,7 +58,7 @@ class StreamReaderTests(test_utils.TestCase):
|
|||
loop=self.loop)
|
||||
self._basetest_open_connection(conn_fut)
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets')
|
||||
@support.skip_unless_bind_unix_socket
|
||||
def test_open_unix_connection(self):
|
||||
with test_utils.run_test_unix_server() as httpd:
|
||||
conn_fut = asyncio.open_unix_connection(httpd.address,
|
||||
|
@ -86,8 +87,8 @@ class StreamReaderTests(test_utils.TestCase):
|
|||
|
||||
self._basetest_open_connection_no_loop_ssl(conn_fut)
|
||||
|
||||
@support.skip_unless_bind_unix_socket
|
||||
@unittest.skipIf(ssl is None, 'No ssl module')
|
||||
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets')
|
||||
def test_open_unix_connection_no_loop_ssl(self):
|
||||
with test_utils.run_test_unix_server(use_ssl=True) as httpd:
|
||||
conn_fut = asyncio.open_unix_connection(
|
||||
|
@ -113,7 +114,7 @@ class StreamReaderTests(test_utils.TestCase):
|
|||
loop=self.loop)
|
||||
self._basetest_open_connection_error(conn_fut)
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets')
|
||||
@support.skip_unless_bind_unix_socket
|
||||
def test_open_unix_connection_error(self):
|
||||
with test_utils.run_test_unix_server() as httpd:
|
||||
conn_fut = asyncio.open_unix_connection(httpd.address,
|
||||
|
@ -634,7 +635,7 @@ class StreamReaderTests(test_utils.TestCase):
|
|||
server.stop()
|
||||
self.assertEqual(msg, b"hello world!\n")
|
||||
|
||||
@unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'No UNIX Sockets')
|
||||
@support.skip_unless_bind_unix_socket
|
||||
def test_start_unix_server(self):
|
||||
|
||||
class MyServer:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue