Those tests may fail with PermissionError.
https://bugs.python.org/issue36341
def new_loop(self):
return asyncio.SelectorEventLoop()
- @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'no Unix sockets')
+ @support.skip_unless_bind_unix_socket
def test_start_unix_server_1(self):
HELLO_MSG = b'1' * 1024 * 5 + b'\n'
started = threading.Event()
self.addCleanup(shutil.rmtree, tmpdir)
s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.addCleanup(s.close)
- s.bind(os.path.join(tmpdir, 'socket'))
- self._test_socket_fileno(s, socket.AF_UNIX, socket.SOCK_STREAM)
+ try:
+ s.bind(os.path.join(tmpdir, 'socket'))
+ except PermissionError:
+ pass
+ else:
+ self._test_socket_fileno(s, socket.AF_UNIX,
+ socket.SOCK_STREAM)
def test_socket_fileno_rejects_float(self):
with self.assertRaisesRegex(TypeError, "integer argument expected"):
import os
import socket
import sys
-from test.support import TESTFN, import_fresh_module
+from test.support import (TESTFN, import_fresh_module,
+ skip_unless_bind_unix_socket)
c_stat = import_fresh_module('stat', fresh=['_stat'])
py_stat = import_fresh_module('stat', blocked=['_stat'])
self.assertS_IS("BLK", st_mode)
break
- @unittest.skipUnless(hasattr(socket, 'AF_UNIX'), 'requires unix socket')
+ @skip_unless_bind_unix_socket
def test_socket(self):
with socket.socket(socket.AF_UNIX) as s:
s.bind(TESTFN)
--- /dev/null
+Fix tests that may fail with PermissionError upon calling bind() on AF_UNIX
+sockets.