bpo-36341: Fix tests calling bind() on AF_UNIX sockets (GH-12399)

Those tests may fail with PermissionError.



https://bugs.python.org/issue36341
This commit is contained in:
xdegaye 2019-05-03 17:09:17 +02:00 committed by Miss Islington (bot)
parent a8a79cacca
commit 4461d704e2
4 changed files with 13 additions and 5 deletions

View file

@ -1796,8 +1796,13 @@ class GeneralModuleTests(unittest.TestCase):
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"):