示例#1
0
 def test_not_only_sockets_in_list(self):
     from waitress.adjustments import as_socket_list
     sockets = [
         socket.socket(socket.AF_INET, socket.SOCK_STREAM),
         socket.socket(socket.AF_INET6, socket.SOCK_STREAM),
         {'something': 'else'}]
     new_sockets = as_socket_list(sockets)
     self.assertEqual(new_sockets, [sockets[0], sockets[1]])
     for sock in [sock for sock in sockets if isinstance(sock, socket.socket)]:
         sock.close()
示例#2
0
 def test_only_sockets_in_list(self):
     from waitress.adjustments import as_socket_list
     sockets = [
         socket.socket(socket.AF_INET, socket.SOCK_STREAM),
         socket.socket(socket.AF_INET6, socket.SOCK_STREAM)]
     if hasattr(socket, 'AF_UNIX'):
         sockets.append(socket.socket(socket.AF_UNIX, socket.SOCK_STREAM))
     new_sockets = as_socket_list(sockets)
     self.assertEqual(sockets, new_sockets)
     for sock in sockets:
         sock.close()