示例#1
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, ))
示例#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)
示例#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,))
示例#4
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)
示例#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))
示例#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))
示例#7
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"
示例#8
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")
示例#9
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))
示例#10
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"
示例#11
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))
示例#12
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")
示例#13
0
 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)
示例#14
0
 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)
示例#15
0
 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, ))
示例#16
0
 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,))
示例#17
0
 def src_addr(self, value):
     self._set_in_headers("SrcAddr",
                          string_to_addr(self.address_family, value))
示例#18
0
 def src_addr(self, value):
     self._set_in_headers("SrcAddr", string_to_addr(self.address_family, value, self.encoding))
示例#19
0
 def dst_addr(self, value):
     self._set_in_headers("DstAddr",
                          string_to_addr(self.address_family, value))
示例#20
0
 def dst_addr(self, value):
     self._set_in_headers("DstAddr", string_to_addr(self.address_family, value, self.encoding))