• Home
  • Raw
  • Download

Lines Matching refs:ipaddress

13 import ipaddress
58 return self.assertCleanError(ipaddress.AddressValueError,
63 return self.assertCleanError(ipaddress.NetmaskValueError,
171 factory = ipaddress.IPv4Address
176 ipaddress.IPv4Address(addr)
181 ipaddress.IPv4Address(addr)
211 ipaddress.IPv4Address(addr)
220 ipaddress.IPv4Address(addr)
236 ipaddress.IPv4Address(addr)
245 ipaddress.IPv4Address(addr)
254 ipaddress.IPv4Address(addr)
267 factory = ipaddress.IPv6Address
272 ipaddress.IPv6Address(addr)
278 ipaddress.IPv6Address(addr)
288 ipaddress.IPv6Address(addr)
301 ipaddress.IPv6Address(addr)
314 ipaddress.IPv6Address(addr)
322 ipaddress.IPv6Address(addr)
339 ipaddress.IPv6Address(addr)
350 ipaddress.IPv6Address(addr)
360 ipaddress.IPv6Address(addr)
377 ipaddress.IPv6Address(addr)
390 ipaddress.IPv6Address(addr)
476 factory = ipaddress.IPv4Interface
480 factory = ipaddress.IPv4Network
520 ipaddress.IPv4Network('10.0.0.0/30').supernet_of(
521 ipaddress.IPv6Network('::1/128'))
523 ipaddress.IPv6Network('::1/128').supernet_of(
524 ipaddress.IPv4Network('10.0.0.0/30'))
526 ipaddress.IPv4Network('10.0.0.0/30').subnet_of(
527 ipaddress.IPv6Network('::1/128'))
529 ipaddress.IPv6Network('::1/128').subnet_of(
530 ipaddress.IPv4Network('10.0.0.0/30'))
589 factory = ipaddress.IPv6Interface
593 factory = ipaddress.IPv6Network
642 self.assertFactoryError(ipaddress.ip_address, "address")
645 self.assertFactoryError(ipaddress.ip_interface, "interface")
648 self.assertFactoryError(ipaddress.ip_network, "network")
667 v4addr = ipaddress.IPv4Address(1)
668 v4net = ipaddress.IPv4Network(1)
669 v4intf = ipaddress.IPv4Interface(1)
670 v6addr = ipaddress.IPv6Address(1)
671 v6net = ipaddress.IPv6Network(1)
672 v6intf = ipaddress.IPv6Interface(1)
681 v4addr2 = ipaddress.IPv4Address(2)
682 v4net2 = ipaddress.IPv4Network(2)
683 v4intf2 = ipaddress.IPv4Interface(2)
684 v6addr2 = ipaddress.IPv6Address(2)
685 v6net2 = ipaddress.IPv6Network(2)
686 v6intf2 = ipaddress.IPv6Interface(2)
779 key=ipaddress.get_mixed_type_key))
782 key=ipaddress.get_mixed_type_key))
785 key=ipaddress.get_mixed_type_key))
786 self.assertEqual(NotImplemented, ipaddress.get_mixed_type_key(object))
790 v4addr = ipaddress.ip_address('1.1.1.1')
791 v4net = ipaddress.ip_network('1.1.1.1')
792 v6addr = ipaddress.ip_address('::1')
793 v6net = ipaddress.ip_network('::1')
809 self.ipv4_address = ipaddress.IPv4Address('1.2.3.4')
810 self.ipv4_interface = ipaddress.IPv4Interface('1.2.3.4/24')
811 self.ipv4_network = ipaddress.IPv4Network('1.2.3.0/24')
813 self.ipv6_address = ipaddress.IPv6Interface(
815 self.ipv6_interface = ipaddress.IPv6Interface(
817 self.ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/64')
821 repr(ipaddress.IPv4Interface('1.2.3.4')))
823 repr(ipaddress.IPv6Interface('::1')))
828 ip = ipaddress.IPv4Address('192.0.2.1')
829 net = ipaddress.IPv4Network('192.0.2.1/32')
830 self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', 32)), net)
831 self.assertEqual(ipaddress.IPv4Network((ip, 32)), net)
832 self.assertEqual(ipaddress.IPv4Network((3221225985, 32)), net)
833 self.assertEqual(ipaddress.IPv4Network(('192.0.2.1',
835 self.assertEqual(ipaddress.IPv4Network((ip,
837 self.assertEqual(ipaddress.IPv4Network((3221225985,
841 ipaddress.IPv4Network(('192.0.2.1', 24))
843 ipaddress.IPv4Network((ip, 24))
845 ipaddress.IPv4Network((3221225985, 24))
847 ipaddress.IPv4Network(('192.0.2.1', '255.255.255.0'))
849 ipaddress.IPv4Network((ip, '255.255.255.0'))
851 ipaddress.IPv4Network((3221225985, '255.255.255.0'))
853 net = ipaddress.IPv4Network('192.0.2.0/24')
854 self.assertEqual(ipaddress.IPv4Network(('192.0.2.1', 24),
856 self.assertEqual(ipaddress.IPv4Network((ip, 24),
858 self.assertEqual(ipaddress.IPv4Network((3221225985, 24),
860 self.assertEqual(ipaddress.IPv4Network(('192.0.2.1',
863 self.assertEqual(ipaddress.IPv4Network((ip,
866 self.assertEqual(ipaddress.IPv4Network((3221225985,
871 ip = ipaddress.IPv4Address('192.0.2.0')
872 net = ipaddress.IPv4Network('192.0.2.0/24')
873 self.assertEqual(ipaddress.IPv4Network(('192.0.2.0',
875 self.assertEqual(ipaddress.IPv4Network((ip,
877 self.assertEqual(ipaddress.IPv4Network((3221225984,
879 self.assertEqual(ipaddress.IPv4Network(('192.0.2.0', 24)), net)
880 self.assertEqual(ipaddress.IPv4Network((ip, 24)), net)
881 self.assertEqual(ipaddress.IPv4Network((3221225984, 24)), net)
883 self.assertEqual(ipaddress.IPv4Interface(('192.0.2.1', 24)),
884 ipaddress.IPv4Interface('192.0.2.1/24'))
885 self.assertEqual(ipaddress.IPv4Interface((3221225985, 24)),
886 ipaddress.IPv4Interface('192.0.2.1/24'))
891 ip = ipaddress.IPv6Address('2001:db8::')
892 net = ipaddress.IPv6Network('2001:db8::/128')
893 self.assertEqual(ipaddress.IPv6Network(('2001:db8::', '128')),
895 self.assertEqual(ipaddress.IPv6Network(
898 self.assertEqual(ipaddress.IPv6Network((ip, '128')),
900 ip = ipaddress.IPv6Address('2001:db8::')
901 net = ipaddress.IPv6Network('2001:db8::/96')
902 self.assertEqual(ipaddress.IPv6Network(('2001:db8::', '96')),
904 self.assertEqual(ipaddress.IPv6Network(
907 self.assertEqual(ipaddress.IPv6Network((ip, '96')),
911 ip = ipaddress.IPv6Address('2001:db8::1')
913 ipaddress.IPv6Network(('2001:db8::1', 96))
915 ipaddress.IPv6Network((
918 ipaddress.IPv6Network((ip, 96))
920 net = ipaddress.IPv6Network('2001:db8::/96')
921 self.assertEqual(ipaddress.IPv6Network(('2001:db8::1', 96),
924 self.assertEqual(ipaddress.IPv6Network(
928 self.assertEqual(ipaddress.IPv6Network((ip, 96), strict=False),
932 self.assertEqual(ipaddress.IPv6Interface(('2001:db8::1', '96')),
933 ipaddress.IPv6Interface('2001:db8::1/96'))
934 self.assertEqual(ipaddress.IPv6Interface(
936 ipaddress.IPv6Interface('2001:db8::1/96'))
940 self.assertEqual(ipaddress.IPv4Address('1.1.1.1') + 255,
941 ipaddress.IPv4Address('1.1.2.0'))
942 self.assertEqual(ipaddress.IPv4Address('1.1.1.1') - 256,
943 ipaddress.IPv4Address('1.1.0.1'))
944 self.assertEqual(ipaddress.IPv6Address('::1') + (2**16 - 2),
945 ipaddress.IPv6Address('::ffff'))
946 self.assertEqual(ipaddress.IPv6Address('::ffff') - (2**16 - 2),
947 ipaddress.IPv6Address('::1'))
950 self.assertRaises(ValueError, ipaddress.v4_int_to_packed, -1)
951 self.assertRaises(ValueError, ipaddress.v4_int_to_packed,
952 2 ** ipaddress.IPV4LENGTH)
953 self.assertRaises(ValueError, ipaddress.v6_int_to_packed, -1)
954 self.assertRaises(ValueError, ipaddress.v6_int_to_packed,
955 2 ** ipaddress.IPV6LENGTH)
958 ip1 = ipaddress.IPv4Address('10.10.10.10')
959 ip2 = ipaddress.IPv4Address('10.10.10.11')
960 ip3 = ipaddress.IPv4Address('10.10.10.12')
961 self.assertEqual(list(ipaddress._find_address_range([ip1])),
963 self.assertEqual(list(ipaddress._find_address_range([ip1, ip3])),
965 self.assertEqual(list(ipaddress._find_address_range([ip1, ip2, ip3])),
967 self.assertEqual(128, ipaddress._count_righthand_zero_bits(0, 128))
971 class Broken(ipaddress._BaseNetwork):
978 class Broken(ipaddress._BaseNetwork):
997 ipaddress.IPv4Interface(16909060)._ip)
999 ipv4 = ipaddress.ip_network('1.2.3.4')
1000 ipv6 = ipaddress.ip_network('2001:658:22a:cafe:200:0:0:1')
1001 self.assertEqual(ipv4, ipaddress.ip_network(int(ipv4.network_address)))
1002 self.assertEqual(ipv6, ipaddress.ip_network(int(ipv6.network_address)))
1006 ipaddress.IPv6Interface(v6_int)._ip)
1008 self.assertEqual(ipaddress.ip_network(self.ipv4_address._ip).version,
1010 self.assertEqual(ipaddress.ip_network(self.ipv6_address._ip).version,
1014 address = ipaddress.ip_address
1016 ipaddress.ip_interface(b'\x01\x02\x03\x04')._ip)
1020 ipaddress.ip_interface(
1046 ipv4_zero_netmask = ipaddress.IPv4Interface('1.2.3.4/0')
1053 ipv6_zero_netmask = ipaddress.IPv6Interface('::1/0')
1070 net = ipaddress.IPv4Network('127.0.0.0/0.0.0.255')
1091 ipaddress.IPv4Interface('0.0.0.0/0').network.supernet(),
1092 ipaddress.IPv4Network('0.0.0.0/0'))
1097 self.assertEqual(ipaddress.IPv6Interface('::0/0').network.supernet(),
1098 ipaddress.IPv6Network('::0/0'))
1127 self.assertEqual(ipaddress.IPv4Address('1.2.3.1'), hosts[0])
1128 self.assertEqual(ipaddress.IPv4Address('1.2.3.254'), hosts[-1])
1130 ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/120')
1133 self.assertEqual(ipaddress.IPv6Address('2001:658:22a:cafe::1'), hosts[0])
1134 self.assertEqual(ipaddress.IPv6Address('2001:658:22a:cafe::ff'), hosts[-1])
1137 addrs = [ipaddress.IPv4Address('2.0.0.0'),
1138 ipaddress.IPv4Address('2.0.0.1')]
1141 self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))
1142 self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))
1143 self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),
1144 list(ipaddress.ip_network(tpl_args).hosts()))
1146 addrs = [ipaddress.IPv6Address('2001:658:22a:cafe::'),
1147 ipaddress.IPv6Address('2001:658:22a:cafe::1')]
1150 self.assertEqual(addrs, list(ipaddress.ip_network(str_args).hosts()))
1151 self.assertEqual(addrs, list(ipaddress.ip_network(tpl_args).hosts()))
1152 self.assertEqual(list(ipaddress.ip_network(str_args).hosts()),
1153 list(ipaddress.ip_network(tpl_args).hosts()))
1183 ip = ipaddress.IPv4Network('1.2.3.4/32')
1190 ip = ipaddress.IPv6Network('::1/128')
1218 ipv6_network = ipaddress.IPv6Network('2001:658:22a:cafe::/120')
1269 self.assertIn(ipaddress.IPv4Interface('1.2.3.128/25'),
1271 self.assertNotIn(ipaddress.IPv4Interface('1.2.4.1/24'),
1274 addr1 = ipaddress.IPv4Address('1.2.3.37')
1278 self.assertFalse(ipaddress.IPv4Network('1.1.0.0/16').__contains__(
1279 ipaddress.IPv4Network('1.0.0.0/15')))
1291 addr = ipaddress.IPv4Network('172.31.255.128/255.255.255.240')
1302 ipaddress.IPv4Interface('1.2.3.4/24'))
1304 ipaddress.IPv4Interface('1.2.3.4/23'))
1306 ipaddress.IPv6Interface('::1.2.3.4/24'))
1312 ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/64'))
1314 ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/63'))
1316 ipaddress.IPv4Interface('1.2.3.4/23'))
1323 ipaddress.IPv4Interface('1.2.3.4/24'))
1325 ipaddress.IPv4Interface('1.2.3.4/23'))
1327 ipaddress.IPv6Interface('::1.2.3.4/24'))
1333 ipaddress.IPv4Address('1.2.3.5'))
1339 ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/64'))
1341 ipaddress.IPv6Interface('2001:658:22a:cafe:200::1/63'))
1343 ipaddress.IPv4Interface('1.2.3.4/23'))
1349 ipaddress.IPv4Address('1.2.3.4'))
1355 self.assertEqual(str(ipaddress.IPv4Interface(
1359 self.assertEqual(str(ipaddress.IPv6Interface('::1/128')),
1363 self.assertEqual(str(ipaddress.IPv4Interface('1.2.3.4/0.0.0.0')),
1368 ip1 = ipaddress.IPv4Address('1.1.1.0')
1369 ip2 = ipaddress.IPv4Address('1.1.1.1')
1370 ip3 = ipaddress.IPv4Address('1.1.1.2')
1371 ip4 = ipaddress.IPv4Address('1.1.1.3')
1372 ip5 = ipaddress.IPv4Address('1.1.1.4')
1373 ip6 = ipaddress.IPv4Address('1.1.1.0')
1375 collapsed = ipaddress.collapse_addresses(
1378 [ipaddress.IPv4Network('1.1.1.0/30'),
1379 ipaddress.IPv4Network('1.1.1.4/32')])
1382 ip1 = ipaddress.IPv4Address('1.1.1.0')
1383 ip2 = ipaddress.IPv4Address('1.1.1.1')
1384 ip3 = ipaddress.IPv4Address('1.1.1.2')
1385 ip4 = ipaddress.IPv4Address('1.1.1.3')
1389 collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3, ip4])
1391 [ipaddress.IPv4Network('1.1.1.0/30')])
1394 ip1 = ipaddress.IPv4Network('1.1.0.0/24')
1395 ip2 = ipaddress.IPv4Network('1.1.1.0/24')
1396 ip3 = ipaddress.IPv4Network('1.1.2.0/24')
1397 ip4 = ipaddress.IPv4Network('1.1.3.0/24')
1398 ip5 = ipaddress.IPv4Network('1.1.4.0/24')
1401 ip6 = ipaddress.IPv4Network('1.1.0.0/22')
1403 collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3, ip4, ip5,
1406 [ipaddress.IPv4Network('1.1.0.0/22'),
1407 ipaddress.IPv4Network('1.1.4.0/24')])
1410 collapsed = ipaddress.collapse_addresses([ip1, ip2])
1412 [ipaddress.IPv4Network('1.1.0.0/23')])
1415 ip_same1 = ip_same2 = ipaddress.IPv4Network('1.1.1.1/32')
1416 self.assertEqual(list(ipaddress.collapse_addresses(
1421 ip_same1 = ip_same2 = ipaddress.IPv4Address('1.1.1.1')
1422 self.assertEqual(list(ipaddress.collapse_addresses(
1424 [ipaddress.ip_network('1.1.1.1/32')])
1425 ip1 = ipaddress.IPv6Network('2001::/100')
1426 ip2 = ipaddress.IPv6Network('2001::/120')
1427 ip3 = ipaddress.IPv6Network('2001::/96')
1429 collapsed = ipaddress.collapse_addresses([ip1, ip2, ip3])
1434 (ipaddress.ip_address('1.1.1.1'),
1435 ipaddress.ip_address('::1')),
1436 (ipaddress.IPv4Network('1.1.0.0/24'),
1437 ipaddress.IPv6Network('2001::/120')),
1438 (ipaddress.IPv4Network('1.1.0.0/32'),
1439 ipaddress.IPv6Network('2001::/128')),
1442 self.assertRaises(TypeError, ipaddress.collapse_addresses,
1448 summarize = ipaddress.summarize_address_range
1449 ip1 = ipaddress.ip_address('1.1.1.0')
1450 ip2 = ipaddress.ip_address('1.1.1.255')
1453 class IPv7Address(ipaddress.IPv6Address):
1463 summarize(ip1, ipaddress.IPv6Address('::1')))
1466 ipaddress.ip_network('1.1.1.0/24'))
1468 ip2 = ipaddress.ip_address('1.1.1.8')
1470 [ipaddress.ip_network('1.1.1.0/29'),
1471 ipaddress.ip_network('1.1.1.8')])
1473 ip1 = ipaddress.IPv4Address(0)
1474 ip2 = ipaddress.IPv4Address(ipaddress.IPv4Address._ALL_ONES)
1475 self.assertEqual([ipaddress.IPv4Network('0.0.0.0/0')],
1478 ip1 = ipaddress.ip_address('1::')
1479 ip2 = ipaddress.ip_address('1:ffff:ffff:ffff:ffff:ffff:ffff:ffff')
1482 ipaddress.ip_network('1::/16'))
1484 ip2 = ipaddress.ip_address('2::')
1486 [ipaddress.ip_network('1::/16'),
1487 ipaddress.ip_network('2::/128')])
1491 summarize(ipaddress.ip_address('1.1.1.0'),
1492 ipaddress.ip_address('1.1.0.0')))
1495 summarize(ipaddress.ip_network('1.1.1.0'),
1496 ipaddress.ip_network('1.1.0.0')))
1498 summarize(ipaddress.ip_network('1.1.1.0'),
1499 ipaddress.ip_network('1.1.0.0')))
1502 summarize(ipaddress.ip_address('::'),
1503 ipaddress.ip_network('1.1.0.0')))
1506 self.assertTrue(ipaddress.ip_address('1.1.1.1') <=
1507 ipaddress.ip_address('1.1.1.1'))
1508 self.assertTrue(ipaddress.ip_address('1.1.1.1') <=
1509 ipaddress.ip_address('1.1.1.2'))
1510 self.assertTrue(ipaddress.ip_address('::1') <=
1511 ipaddress.ip_address('::1'))
1512 self.assertTrue(ipaddress.ip_address('::1') <=
1513 ipaddress.ip_address('::2'))
1516 self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') ==
1517 ipaddress.ip_interface('1.1.1.1/24'))
1518 self.assertTrue(ipaddress.ip_interface('1.1.1.1/16') <
1519 ipaddress.ip_interface('1.1.1.1/24'))
1520 self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') <
1521 ipaddress.ip_interface('1.1.1.2/24'))
1522 self.assertTrue(ipaddress.ip_interface('1.1.1.2/16') <
1523 ipaddress.ip_interface('1.1.1.1/24'))
1524 self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') >
1525 ipaddress.ip_interface('1.1.1.1/16'))
1526 self.assertTrue(ipaddress.ip_interface('1.1.1.2/24') >
1527 ipaddress.ip_interface('1.1.1.1/24'))
1528 self.assertTrue(ipaddress.ip_interface('1.1.1.1/24') >
1529 ipaddress.ip_interface('1.1.1.2/16'))
1531 self.assertTrue(ipaddress.ip_interface('::1/64') ==
1532 ipaddress.ip_interface('::1/64'))
1533 self.assertTrue(ipaddress.ip_interface('::1/64') <
1534 ipaddress.ip_interface('::1/80'))
1535 self.assertTrue(ipaddress.ip_interface('::1/64') <
1536 ipaddress.ip_interface('::2/64'))
1537 self.assertTrue(ipaddress.ip_interface('::2/48') <
1538 ipaddress.ip_interface('::1/64'))
1539 self.assertTrue(ipaddress.ip_interface('::1/80') >
1540 ipaddress.ip_interface('::1/64'))
1541 self.assertTrue(ipaddress.ip_interface('::2/64') >
1542 ipaddress.ip_interface('::1/64'))
1543 self.assertTrue(ipaddress.ip_interface('::1/64') >
1544 ipaddress.ip_interface('::2/48'))
1548 ip1 = ipaddress.IPv4Network('1.1.1.0/24')
1549 ip2 = ipaddress.IPv4Network('1.1.1.0/32')
1550 ip3 = ipaddress.IPv4Network('1.1.2.0/24')
1565 ip1 = ipaddress.IPv6Network('2001:2000::/96')
1566 ip2 = ipaddress.IPv6Network('2001:2001::/96')
1567 ip3 = ipaddress.IPv6Network('2001:ffff:2000::/96')
1579 ipv6 = ipaddress.IPv6Interface('::/0')
1580 ipv4 = ipaddress.IPv4Interface('0.0.0.0/0')
1587 ip1 = ipaddress.ip_network('10.1.2.128/25')
1590 ip2 = ipaddress.ip_network('10.1.3.0/24')
1595 ip3 = ipaddress.ip_network('10.1.3.0/25')
1602 ip1 = ipaddress.ip_network('10.10.10.0/31')
1603 ip2 = ipaddress.ip_network('10.10.10.0')
1604 ip3 = ipaddress.ip_network('10.10.10.2/31')
1605 ip4 = ipaddress.ip_network('10.10.10.2')
1613 self.assertIs(ip1.__lt__(ipaddress.ip_address('10.10.10.0')),
1615 self.assertIs(ip2.__lt__(ipaddress.ip_address('10.10.10.0')),
1619 self.assertTrue(ipaddress.ip_network('1.1.1.1') <=
1620 ipaddress.ip_network('1.1.1.1'))
1621 self.assertTrue(ipaddress.ip_network('1.1.1.1') <=
1622 ipaddress.ip_network('1.1.1.2'))
1623 self.assertFalse(ipaddress.ip_network('1.1.1.2') <=
1624 ipaddress.ip_network('1.1.1.1'))
1625 self.assertTrue(ipaddress.ip_network('::1') <=
1626 ipaddress.ip_network('::1'))
1627 self.assertTrue(ipaddress.ip_network('::1') <=
1628 ipaddress.ip_network('::2'))
1629 self.assertFalse(ipaddress.ip_network('::2') <=
1630 ipaddress.ip_network('::1'))
1633 self.assertRaises(ValueError, ipaddress.ip_network, '192.168.1.1/24')
1634 self.assertRaises(ValueError, ipaddress.ip_network, '::1/120')
1637 other = ipaddress.IPv4Network('1.2.3.0/30')
1638 other2 = ipaddress.IPv4Network('1.2.2.0/24')
1639 other3 = ipaddress.IPv4Network('1.2.2.64/26')
1646 ipv4 = ipaddress.IPv4Interface(ipv4_string)
1647 v4compat_ipv6 = ipaddress.IPv6Interface('::%s' % ipv4_string)
1649 v4mapped_ipv6 = ipaddress.IPv6Interface('::ffff:%s' % ipv4_string)
1651 self.assertRaises(ipaddress.AddressValueError, ipaddress.IPv6Interface,
1657 self.assertEqual(ipaddress.ip_address('::FFFF:192.0.2.1'),
1658 ipaddress.ip_address('::FFFF:c000:201'))
1660 self.assertEqual(ipaddress.ip_address('FFFF::192.0.2.1'),
1661 ipaddress.ip_address('FFFF::c000:201'))
1674 self.assertEqual(ipaddress.IPv4Interface('255.254.253.252').packed,
1679 self.assertEqual(ipaddress.IPv6Interface('ffff:2:3:4:ffff::').packed,
1682 self.assertEqual(ipaddress.IPv6Interface('::1:0:0:0:0').packed,
1686 ipv4net = ipaddress.ip_network('1.2.3.4')
1687 ipv4addr = ipaddress.ip_address('1.2.3.4')
1688 ipv6net = ipaddress.ip_network('::1.2.3.4')
1689 ipv6addr = ipaddress.ip_address('::1.2.3.4')
1690 self.assertEqual(ipaddress.IPv4Network, type(ipv4net))
1691 self.assertEqual(ipaddress.IPv4Address, type(ipv4addr))
1692 self.assertEqual(ipaddress.IPv6Network, type(ipv6net))
1693 self.assertEqual(ipaddress.IPv6Address, type(ipv6addr))
1697 self.assertEqual(True, ipaddress.ip_interface(
1699 self.assertEqual(False, ipaddress.ip_network('240.0.0.0').is_multicast)
1700 self.assertEqual(True, ipaddress.ip_network('240.0.0.0').is_reserved)
1702 self.assertEqual(True, ipaddress.ip_interface(
1704 self.assertEqual(False, ipaddress.ip_network('192.169.0.0').is_private)
1705 self.assertEqual(True, ipaddress.ip_network(
1707 self.assertEqual(False, ipaddress.ip_network('11.0.0.0').is_private)
1708 self.assertEqual(False, ipaddress.ip_network('11.0.0.0').is_reserved)
1709 self.assertEqual(True, ipaddress.ip_network(
1711 self.assertEqual(False, ipaddress.ip_network('172.32.0.0').is_private)
1713 ipaddress.ip_network('169.254.1.0/24').is_link_local)
1716 ipaddress.ip_interface(
1719 ipaddress.ip_interface(
1723 ipaddress.ip_network(
1725 self.assertEqual(True, ipaddress.ip_network(
1727 self.assertEqual(False, ipaddress.ip_network('128.0.0.0').is_loopback)
1729 ipaddress.ip_network('100.64.0.0/10').is_private)
1730 self.assertEqual(False, ipaddress.ip_network('100.64.0.0/10').is_global)
1733 ipaddress.ip_network('192.0.2.128/25').is_private)
1735 ipaddress.ip_network('192.0.3.0/24').is_global)
1738 self.assertEqual(True, ipaddress.ip_address('0.0.0.0').is_unspecified)
1739 self.assertEqual(True, ipaddress.ip_address('224.1.1.1').is_multicast)
1740 self.assertEqual(False, ipaddress.ip_address('240.0.0.0').is_multicast)
1741 self.assertEqual(True, ipaddress.ip_address('240.0.0.1').is_reserved)
1743 ipaddress.ip_address('239.255.255.255').is_reserved)
1745 self.assertEqual(True, ipaddress.ip_address('192.168.1.1').is_private)
1746 self.assertEqual(False, ipaddress.ip_address('192.169.0.0').is_private)
1747 self.assertEqual(True, ipaddress.ip_address(
1749 self.assertEqual(False, ipaddress.ip_address('11.0.0.0').is_private)
1750 self.assertEqual(True, ipaddress.ip_address(
1752 self.assertEqual(False, ipaddress.ip_address('172.32.0.0').is_private)
1755 ipaddress.ip_address('169.254.100.200').is_link_local)
1757 ipaddress.ip_address('169.255.100.200').is_link_local)
1759 self.assertTrue(ipaddress.ip_address('192.0.7.1').is_global)
1760 self.assertFalse(ipaddress.ip_address('203.0.113.1').is_global)
1763 ipaddress.ip_address('127.100.200.254').is_loopback)
1764 self.assertEqual(True, ipaddress.ip_address('127.42.0.0').is_loopback)
1765 self.assertEqual(False, ipaddress.ip_address('128.0.0.0').is_loopback)
1766 self.assertEqual(True, ipaddress.ip_network('0.0.0.0').is_unspecified)
1770 self.assertEqual(True, ipaddress.ip_network('ffff::').is_multicast)
1771 self.assertEqual(True, ipaddress.ip_network(2**128 - 1).is_multicast)
1772 self.assertEqual(True, ipaddress.ip_network('ff00::').is_multicast)
1773 self.assertEqual(False, ipaddress.ip_network('fdff::').is_multicast)
1775 self.assertEqual(True, ipaddress.ip_network('fecf::').is_site_local)
1776 self.assertEqual(True, ipaddress.ip_network(
1778 self.assertEqual(False, ipaddress.ip_network(
1780 self.assertEqual(False, ipaddress.ip_network('ff00::').is_site_local)
1782 self.assertEqual(True, ipaddress.ip_network('fc00::').is_private)
1783 self.assertEqual(True, ipaddress.ip_network(
1785 self.assertEqual(False, ipaddress.ip_network('fbff:ffff::').is_private)
1786 self.assertEqual(False, ipaddress.ip_network('fe00::').is_private)
1788 self.assertEqual(True, ipaddress.ip_network('fea0::').is_link_local)
1789 self.assertEqual(True, ipaddress.ip_network(
1791 self.assertEqual(False, ipaddress.ip_network(
1793 self.assertEqual(False, ipaddress.ip_network('fec0::').is_link_local)
1795 self.assertEqual(True, ipaddress.ip_interface('0:0::0:01').is_loopback)
1796 self.assertEqual(False, ipaddress.ip_interface('::1/127').is_loopback)
1797 self.assertEqual(False, ipaddress.ip_network('::').is_loopback)
1798 self.assertEqual(False, ipaddress.ip_network('::2').is_loopback)
1800 self.assertEqual(True, ipaddress.ip_network('0::0').is_unspecified)
1801 self.assertEqual(False, ipaddress.ip_network('::1').is_unspecified)
1802 self.assertEqual(False, ipaddress.ip_network('::/127').is_unspecified)
1805 ipaddress.ip_network('2001::1/128').is_private)
1807 ipaddress.ip_network('200::1/128').is_global)
1809 self.assertEqual(True, ipaddress.ip_address('ffff::').is_multicast)
1810 self.assertEqual(True, ipaddress.ip_address(2**128 - 1).is_multicast)
1811 self.assertEqual(True, ipaddress.ip_address('ff00::').is_multicast)
1812 self.assertEqual(False, ipaddress.ip_address('fdff::').is_multicast)
1814 self.assertEqual(True, ipaddress.ip_address('fecf::').is_site_local)
1815 self.assertEqual(True, ipaddress.ip_address(
1817 self.assertEqual(False, ipaddress.ip_address(
1819 self.assertEqual(False, ipaddress.ip_address('ff00::').is_site_local)
1821 self.assertEqual(True, ipaddress.ip_address('fc00::').is_private)
1822 self.assertEqual(True, ipaddress.ip_address(
1824 self.assertEqual(False, ipaddress.ip_address('fbff:ffff::').is_private)
1825 self.assertEqual(False, ipaddress.ip_address('fe00::').is_private)
1827 self.assertEqual(True, ipaddress.ip_address('fea0::').is_link_local)
1828 self.assertEqual(True, ipaddress.ip_address(
1830 self.assertEqual(False, ipaddress.ip_address(
1832 self.assertEqual(False, ipaddress.ip_address('fec0::').is_link_local)
1834 self.assertEqual(True, ipaddress.ip_address('0:0::0:01').is_loopback)
1835 self.assertEqual(True, ipaddress.ip_address('::1').is_loopback)
1836 self.assertEqual(False, ipaddress.ip_address('::2').is_loopback)
1838 self.assertEqual(True, ipaddress.ip_address('0::0').is_unspecified)
1839 self.assertEqual(False, ipaddress.ip_address('::1').is_unspecified)
1842 self.assertEqual(True, ipaddress.ip_address('100::').is_reserved)
1843 self.assertEqual(True, ipaddress.ip_network('4000::1/128').is_reserved)
1847 ipaddress.ip_address('::ffff:192.168.1.1').ipv4_mapped,
1848 ipaddress.ip_address('192.168.1.1'))
1849 self.assertEqual(ipaddress.ip_address('::c0a8:101').ipv4_mapped, None)
1850 self.assertEqual(ipaddress.ip_address('::ffff:c0a8:101').ipv4_mapped,
1851 ipaddress.ip_address('192.168.1.1'))
1854 addr1 = ipaddress.ip_network('10.1.1.0/24')
1855 addr2 = ipaddress.ip_network('10.1.1.0/26')
1856 addr3 = ipaddress.ip_network('10.2.1.0/24')
1857 addr4 = ipaddress.ip_address('10.1.1.0')
1858 addr5 = ipaddress.ip_network('2001:db8::0/32')
1859 addr6 = ipaddress.ip_network('10.1.1.5/32')
1861 [ipaddress.ip_network('10.1.1.64/26'),
1862 ipaddress.ip_network('10.1.1.128/25')])
1868 [ipaddress.ip_network('10.1.1.0/30'),
1869 ipaddress.ip_network('10.1.1.4/32'),
1870 ipaddress.ip_network('10.1.1.6/31'),
1871 ipaddress.ip_network('10.1.1.8/29'),
1872 ipaddress.ip_network('10.1.1.16/28'),
1873 ipaddress.ip_network('10.1.1.32/27'),
1874 ipaddress.ip_network('10.1.1.64/26'),
1875 ipaddress.ip_network('10.1.1.128/25')])
1878 self.assertEqual(hash(ipaddress.ip_interface('10.1.1.0/24')),
1879 hash(ipaddress.ip_interface('10.1.1.0/24')))
1880 self.assertEqual(hash(ipaddress.ip_network('10.1.1.0/24')),
1881 hash(ipaddress.ip_network('10.1.1.0/24')))
1882 self.assertEqual(hash(ipaddress.ip_address('10.1.1.0')),
1883 hash(ipaddress.ip_address('10.1.1.0')))
1885 self.assertEqual(hash(ipaddress.ip_address('1.2.3.4')),
1886 hash(ipaddress.ip_address(
1887 int(ipaddress.ip_address('1.2.3.4')._ip))))
1888 ip1 = ipaddress.ip_address('10.1.1.0')
1889 ip2 = ipaddress.ip_address('1::')
1921 addr1 = ipaddress.ip_network('10.1.1.0/24')
1922 addr2 = ipaddress.ip_network(addr1)
1923 addr3 = ipaddress.ip_interface('2001:658:22a:cafe:200::1/64')
1924 addr4 = ipaddress.ip_interface(addr3)
1925 addr5 = ipaddress.IPv4Address('1.1.1.1')
1926 addr6 = ipaddress.IPv6Address('2001:658:22a:cafe:200::1')
1930 self.assertEqual(addr5, ipaddress.IPv4Address(addr5))
1931 self.assertEqual(addr6, ipaddress.IPv6Address(addr6))
1956 self.assertEqual(compressed, str(ipaddress.IPv6Interface(
1960 addr1 = ipaddress.IPv6Interface('2001::1')
1961 addr2 = ipaddress.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1')
1962 addr3 = ipaddress.IPv6Network('2001::/96')
1963 addr4 = ipaddress.IPv4Address('192.168.178.1')
1967 ipaddress.IPv6Interface('::1/128').exploded)
1976 addr1 = ipaddress.IPv4Address('127.0.0.1')
1977 addr2 = ipaddress.IPv6Address('2001:db8::1')
1989 self.assertEqual(ipaddress.ip_network(1).version, 4)
1990 self.assertEqual(ipaddress.IPv6Network(1).version, 6)
2016 ipaddress.IPv4Address('1.2.3.0'))
2018 ipaddress.IPv4Address('1.2.3.255'))
2020 ipaddress.IPv4Address('0.0.0.255'))
2032 ipaddress.IPv6Address('2001:658:22a:cafe::'))
2034 ipaddress.IPv6Address('2001:658:22a:cafe::'))
2038 ipaddress.IPv6Address('2001:658:22a:cafe:ffff:ffff:ffff:ffff'))
2040 ipaddress.IPv6Address('::ffff:ffff:ffff:ffff'))
2043 ipaddress.IPv6Address('2001:658:22a:cafe:ffff:ffff:ffff:ffff'))
2045 ipaddress.IPv6Address('::ffff:ffff:ffff:ffff'))
2055 server = ipaddress.IPv4Address('65.54.227.120')
2056 client = ipaddress.IPv4Address('192.0.2.45')
2059 ipaddress.ip_address(teredo_addr).teredo)
2061 self.assertFalse(ipaddress.ip_address(bad_addr).teredo)
2063 self.assertFalse(ipaddress.ip_address(bad_addr).teredo)
2066 teredo_addr = ipaddress.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1')
2067 self.assertEqual((ipaddress.IPv4Address('94.245.121.253'),
2068 ipaddress.IPv4Address('95.26.244.94')),
2072 sixtofouraddr = ipaddress.ip_address('2002:ac1d:2d64::1')
2073 bad_addr = ipaddress.ip_address('2000:ac1d:2d64::1')
2074 self.assertEqual(ipaddress.IPv4Address('172.29.45.100'),