summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-06-09 05:52:42 +0000
committerpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2010-06-09 05:52:42 +0000
commit5c32cd525c0cf5233315ec46a0ec96f7f98e3213 (patch)
tree0727aca9328670c0ed4b7188b861bbdec96853c1
parent899da1f64462ff22b9f1387dfd9dd58edda1e8eb (diff)
downloadipaddr-py-5c32cd525c0cf5233315ec46a0ec96f7f98e3213.tar.gz
+ fix for issue61.
problem with like-ip'd network objects that had the same broadcast address. git-svn-id: https://ipaddr-py.googlecode.com/svn@171 09200d28-7f98-11dd-ad27-0f66e57d2035
-rw-r--r--trunk/ipaddr.py4
-rwxr-xr-xtrunk/ipaddr_test.py6
2 files changed, 6 insertions, 4 deletions
diff --git a/trunk/ipaddr.py b/trunk/ipaddr.py
index 78f6b63..2f4a716 100644
--- a/trunk/ipaddr.py
+++ b/trunk/ipaddr.py
@@ -593,8 +593,8 @@ class _BaseNet(_IPAddrBase):
def __contains__(self, other):
# dealing with another network.
if isinstance(other, _BaseNet):
- return (int(self.network) <= int(other._ip) and
- int(self.broadcast) >= int(other.broadcast))
+ return (self.network <= other.network and
+ self.broadcast >= other.broadcast)
# dealing with another address
else:
return (int(self.network) <= int(other._ip) <=
diff --git a/trunk/ipaddr_test.py b/trunk/ipaddr_test.py
index 37880aa..61ac4b0 100755
--- a/trunk/ipaddr_test.py
+++ b/trunk/ipaddr_test.py
@@ -351,13 +351,15 @@ class IpaddrUnitTest(unittest.TestCase):
def testContains(self):
self.assertTrue(ipaddr.IPv4Network('1.2.3.128/25') in self.ipv4)
self.assertFalse(ipaddr.IPv4Network('1.2.4.1/24') in self.ipv4)
- self.assertFalse(self.ipv4 in self.ipv6)
- self.assertFalse(self.ipv6 in self.ipv4)
self.assertTrue(self.ipv4 in self.ipv4)
self.assertTrue(self.ipv6 in self.ipv6)
# We can test addresses and string as well.
addr1 = ipaddr.IPv4Address('1.2.3.37')
self.assertTrue(addr1 in self.ipv4)
+ # issue 61, bad network comparison on like-ip'd network objects
+ # with identical broadcast addresses.
+ self.assertFalse(ipaddr.IPv4Network('1.1.0.0/16').__contains__(
+ ipaddr.IPv4Network('1.0.0.0/15')))
def testBadAddress(self):
self.assertRaises(ipaddr.AddressValueError, ipaddr.IPv4Network,