diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 14:04:12 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2011-12-16 14:04:12 (GMT) |
commit | 1637487a0c7f4995d7064fb7df1eab864be755d5 (patch) | |
tree | 4127fc9ae17db698fe6b3470accb465f8d7f2a40 | |
parent | 6ec29e299b663662a1610a740c4c7f8066fc63a6 (diff) | |
download | cpython-1637487a0c7f4995d7064fb7df1eab864be755d5.zip cpython-1637487a0c7f4995d7064fb7df1eab864be755d5.tar.gz cpython-1637487a0c7f4995d7064fb7df1eab864be755d5.tar.bz2 |
Skip test if the path is too long for a AF_UNIX socket
-rw-r--r-- | Lib/test/test_socket.py | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 78bb37c..9deee01 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -4268,17 +4268,29 @@ class TestUnixDomain(unittest.TestCase): "system encoding {1!r}".format( path, sys.getfilesystemencoding())) + def bind(self, sock, path): + # Bind the socket + try: + sock.bind(path) + except OSError as e: + if str(e) == "AF_UNIX path too long": + self.skipTest( + "Pathname {0!a} is too long to serve as a AF_UNIX path" + .format(path)) + else: + raise + def testStrAddr(self): # Test binding to and retrieving a normal string pathname. path = os.path.abspath(support.TESTFN) - self.sock.bind(path) + self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) def testBytesAddr(self): # Test binding to a bytes pathname. path = os.path.abspath(support.TESTFN) - self.sock.bind(self.encoded(path)) + self.bind(self.sock, self.encoded(path)) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) @@ -4287,7 +4299,7 @@ class TestUnixDomain(unittest.TestCase): # non-ASCII bytes supplied using surrogateescape encoding. path = os.path.abspath(support.TESTFN_UNICODE) b = self.encoded(path) - self.sock.bind(b.decode("ascii", "surrogateescape")) + self.bind(self.sock, b.decode("ascii", "surrogateescape")) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) @@ -4297,7 +4309,7 @@ class TestUnixDomain(unittest.TestCase): if support.TESTFN_UNENCODABLE is None: self.skipTest("No unencodable filename available") path = os.path.abspath(support.TESTFN_UNENCODABLE) - self.sock.bind(path) + self.bind(self.sock, path) self.addCleanup(support.unlink, path) self.assertEqual(self.sock.getsockname(), path) |