diff options
author | mshields@google.com <mshields@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035> | 2009-06-01 23:03:25 +0000 |
---|---|---|
committer | mshields@google.com <mshields@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035> | 2009-06-01 23:03:25 +0000 |
commit | 4d2a3f0ffa357372bc3ca3481950a484946eea6b (patch) | |
tree | 14bfbe16b98ff6676b53f45e96dd60180d62870d /branches/1.1.x | |
parent | 4624ecac7d4160ffb7d9380afa8afab9db689a4f (diff) | |
download | ipaddr-py-4d2a3f0ffa357372bc3ca3481950a484946eea6b.tar.gz |
Merge r77, fixing issue 19. Release 1.1.1.
git-svn-id: https://ipaddr-py.googlecode.com/svn@79 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'branches/1.1.x')
-rw-r--r-- | branches/1.1.x/ipaddr.py | 22 | ||||
-rwxr-xr-x | branches/1.1.x/ipaddr_test.py | 15 |
2 files changed, 30 insertions, 7 deletions
diff --git a/branches/1.1.x/ipaddr.py b/branches/1.1.x/ipaddr.py index 4248ea4..af00d87 100644 --- a/branches/1.1.x/ipaddr.py +++ b/branches/1.1.x/ipaddr.py @@ -22,7 +22,7 @@ and prefixes. """ -__version__ = '1.1.0' +__version__ = '1.1.1' import struct @@ -227,17 +227,25 @@ class BaseIP(object): def __lt__(self, other): try: - return (self.version < other.version - or self.ip < other.ip - or self.netmask < other.netmask) + if self.version != other.version: + return self.version < other.version + if self.ip != other.ip: + return self.ip < other.ip + if self.netmask != other.netmask: + return self.netmask < other.netmask + return False except AttributeError: return NotImplemented def __gt__(self, other): try: - return (self.version > other.version - or self.ip > other.ip - or self.netmask > other.netmask) + if self.version != other.version: + return self.version > other.version + if self.ip != other.ip: + return self.ip > other.ip + if self.netmask != other.netmask: + return self.netmask > other.netmask + return False except AttributeError: return NotImplemented diff --git a/branches/1.1.x/ipaddr_test.py b/branches/1.1.x/ipaddr_test.py index b80dc3f..255bb2e 100755 --- a/branches/1.1.x/ipaddr_test.py +++ b/branches/1.1.x/ipaddr_test.py @@ -399,6 +399,21 @@ class IpaddrUnitTest(unittest.TestCase): self.assertTrue(ipv6 > ipv4) self.assertTrue(ipv4 < ipv6) + # Regression test for issue 19. + ip1 = ipaddr.IP('10.1.2.128/25') + self.assertFalse(ip1 < ip1) + self.assertFalse(ip1 > ip1) + ip2 = ipaddr.IP('10.1.3.0/24') + self.assertTrue(ip1 < ip2) + self.assertFalse(ip2 < ip1) + self.assertFalse(ip1 > ip2) + self.assertTrue(ip2 > ip1) + ip3 = ipaddr.IP('10.1.3.0/25') + self.assertTrue(ip2 < ip3) + self.assertFalse(ip3 < ip2) + self.assertFalse(ip2 > ip3) + self.assertTrue(ip3 > ip2) + def testEmbeddedIpv4(self): ipv4_string = '192.168.0.1' ipv4 = ipaddr.IPv4(ipv4_string) |