Skip to content

Commit

Permalink
Adjust test for 3.10 semantics of is_private on networks
Browse files Browse the repository at this point in the history
In 3.10 and below, is_private checks whether the network and broadcast
address are both private.
In later versions (where the test wss backported from), it checks
whether they both are in the same private network.

For 0.0.0.0/0, both 0.0.0.0 and 255.225.255.255 are private,
but one is in 0.0.0.0/8 ("This network") and the other in
255.255.255.255/32 ("Limited broadcast").
  • Loading branch information
encukou committed Apr 24, 2024
1 parent 0740166 commit 554b28c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/test/test_ipaddress.py
Expand Up @@ -2283,7 +2283,7 @@ def testReservedIpv4(self):
self.assertEqual(True, ipaddress.ip_network('0.0.0.0').is_unspecified)

def testPrivateNetworks(self):
self.assertEqual(False, ipaddress.ip_network("0.0.0.0/0").is_private)
self.assertEqual(True, ipaddress.ip_network("0.0.0.0/0").is_private)
self.assertEqual(False, ipaddress.ip_network("1.0.0.0/8").is_private)

self.assertEqual(True, ipaddress.ip_network("0.0.0.0/8").is_private)
Expand Down

0 comments on commit 554b28c

Please sign in to comment.