Skip to content

Commit 8a468af

Browse files
author
David Groves
committed
Added specific tests for first_address and last_address for IPv4Networks
1 parent 27f6fc0 commit 8a468af

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_ipaddress.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2775,5 +2775,18 @@ def test_ipv6_broadcast_address_deprecation(self):
27752775
self.assertIn("IPv6 has no broadcast addresses", str(warn.warning))
27762776
self.assertIn("consider using last_address instead", str(warn.warning))
27772777

2778+
def test_ipv4_first_address(self):
2779+
network = ipaddress.IPv4Network('192.0.2.0/24')
2780+
addr = network.first_address
2781+
self.assertEqual(addr, ipaddress.IPv4Address("192.0.2.0"))
2782+
self.assertEqual(int(addr), 3221225984)
2783+
2784+
def test_ipv4_last_address(self):
2785+
network = ipaddress.IPv4Network('192.0.2.0/24')
2786+
addr = network.last_address
2787+
self.assertEqual(addr, ipaddress.IPv4Address("192.0.2.255"))
2788+
self.assertEqual(int(addr), 3221226239)
2789+
2790+
27782791
if __name__ == '__main__':
27792792
unittest.main()

0 commit comments

Comments
 (0)