def human_readable_address(self): if self.human_readable: return self.human_readable else: try: if self.address_type == NetworkAddress.Family.INET: return socket.inet_ntoa(str(self.packed_bytes)) else: return ipv6_utils.InetNtoA(str(self.packed_bytes)) except ValueError as e: return str(e)
def testInetNtoA(self): for address in ipv6_addresses.IPV6_ADDRESSES: packed = socket.inet_pton(socket.AF_INET6, address) self.assertEqual(ipv6_utils.InetNtoA(packed), socket.inet_ntop(socket.AF_INET6, packed))