Exemple #1
0
 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)
Exemple #2
0
 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)
Exemple #3
0
 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,))
Exemple #4
0
 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, ))
Exemple #5
0
 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))
Exemple #6
0
 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))
Exemple #7
0
 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")
Exemple #8
0
 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"
Exemple #9
0
 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")
Exemple #10
0
 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))
Exemple #11
0
 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"
Exemple #12
0
 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))
Exemple #13
0
 def dst_addr(self):
     header, dst_addr = self._get_from_headers("DstAddr")
     if dst_addr:
         return addr_to_string(self.address_family, dst_addr, self.encoding)
Exemple #14
0
 def src_addr(self):
     header, src_addr = self._get_from_headers("SrcAddr")
     if src_addr:
         return addr_to_string(self.address_family, src_addr, self.encoding)
Exemple #15
0
 def dst_addr(self):
     header, dst_addr = self._get_from_headers("DstAddr")
     if dst_addr:
         return addr_to_string(self.address_family, dst_addr)
Exemple #16
0
 def src_addr(self):
     header, src_addr = self._get_from_headers("SrcAddr")
     if src_addr:
         return addr_to_string(self.address_family, src_addr)