MCPcopy Index your code
hub / github.com/python/cpython / testFancySubnetting

Method testFancySubnetting

Lib/test/test_ipaddress.py:1562–1583  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1560 list(ipaddress.ip_network(tpl_args).hosts()))
1561
1562 def testFancySubnetting(self):
1563 self.assertEqual(sorted(self.ipv4_network.subnets(prefixlen_diff=3)),
1564 sorted(self.ipv4_network.subnets(new_prefix=27)))
1565 self.assertRaises(ValueError, list,
1566 self.ipv4_network.subnets(new_prefix=23))
1567 self.assertRaises(ValueError, list,
1568 self.ipv4_network.subnets(prefixlen_diff=3,
1569 new_prefix=27))
1570 self.assertEqual(sorted(self.ipv6_network.subnets(prefixlen_diff=4)),
1571 sorted(self.ipv6_network.subnets(new_prefix=68)))
1572 self.assertRaises(ValueError, list,
1573 self.ipv6_network.subnets(new_prefix=63))
1574 self.assertRaises(ValueError, list,
1575 self.ipv6_network.subnets(prefixlen_diff=4,
1576 new_prefix=68))
1577 self.assertEqual(sorted(self.ipv6_scoped_network.subnets(prefixlen_diff=4)),
1578 sorted(self.ipv6_scoped_network.subnets(new_prefix=68)))
1579 self.assertRaises(ValueError, list,
1580 self.ipv6_scoped_network.subnets(new_prefix=63))
1581 self.assertRaises(ValueError, list,
1582 self.ipv6_scoped_network.subnets(prefixlen_diff=4,
1583 new_prefix=68))
1584
1585 def testGetSubnets(self):
1586 self.assertEqual(list(self.ipv4_network.subnets())[0].prefixlen, 25)

Callers

nothing calls this directly

Calls 3

subnetsMethod · 0.80
assertEqualMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected