def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET, address) with pytest.raises(ValueError): addr_to_string(addr_fam, (addr, ))
def test_ipv6_wrong_address_family(self): """ Tests IPv6 address conversions """ address = "2607:f0d0:1002:0051:0000:0000:0000:0004" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET6, address) with pytest.raises(ValueError): addr_to_string(addr_fam, addr)
def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 with pytest.raises(ValueError): string_to_addr(addr_fam, address) addr = string_to_addr(socket.AF_INET, address) with pytest.raises(ValueError): addr_to_string(addr_fam, (addr,))
def test_ipv4_address_conversion(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = socket.AF_INET assert address == addr_to_string(addr_fam, string_to_addr(addr_fam, address))
def test_ipv4_loopback_conversion(self): """ Tests IPv4 loopback address conversions """ address = "127.0.0.1" addr_fam = socket.AF_INET assert address == addr_to_string(addr_fam, string_to_addr(addr_fam, address))
def test_ipv6_loopback_conversion(self): """ Tests IPv6 loopback address conversions """ address = "::1" addr_fam = socket.AF_INET6 ipv6 = addr_to_string(addr_fam, string_to_addr(addr_fam, address)) assert ipv6 in "::1"
def test_ipv6_address_conversion(self): """ Tests IPv6 address conversions """ address = "2607:f0d0:1002:0051:0000:0000:0000:0004" addr_fam = socket.AF_INET6 ipv6 = addr_to_string(addr_fam, string_to_addr(addr_fam, address)) assert ipv6 in (address, "2607:f0d0:1002:51::4")
def test_ipv6_wrong_address_family(self): """ Tests IPv6 address conversions """ address = "2607:f0d0:1002:0051:0000:0000:0000:0004" addr_fam = -1 self.assertRaises(ValueError, string_to_addr, addr_fam, address) addr = string_to_addr(socket.AF_INET6, address) self.assertRaises(ValueError, addr_to_string, addr_fam, addr)
def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 self.assertRaises(ValueError, string_to_addr, addr_fam, address) addr = string_to_addr(socket.AF_INET, address) self.assertRaises(ValueError, addr_to_string, addr_fam, (addr, ))
def test_ipv4_wrong_address_family(self): """ Tests IPv4 address conversions """ address = "192.168.1.1" addr_fam = -1 self.assertRaises(ValueError, string_to_addr, addr_fam, address) addr = string_to_addr(socket.AF_INET, address) self.assertRaises(ValueError, addr_to_string, addr_fam, (addr,))
def src_addr(self, value): self._set_in_headers("SrcAddr", string_to_addr(self.address_family, value))
def src_addr(self, value): self._set_in_headers("SrcAddr", string_to_addr(self.address_family, value, self.encoding))
def dst_addr(self, value): self._set_in_headers("DstAddr", string_to_addr(self.address_family, value))
def dst_addr(self, value): self._set_in_headers("DstAddr", string_to_addr(self.address_family, value, self.encoding))