From: Andrew Roberts Date: Fri, 23 Jan 2015 17:24:01 +0000 (-0500) Subject: fix bug with != operator against a string X-Git-Tag: v0.4.30~1^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=6e1060b65d4389be4bba3e2e6c6daa7a424aabeb;p=flanker.git fix bug with != operator against a string --- diff --git a/flanker/addresslib/address.py b/flanker/addresslib/address.py index 6fb098d..a183a78 100644 --- a/flanker/addresslib/address.py +++ b/flanker/addresslib/address.py @@ -427,6 +427,13 @@ class EmailAddress(Address): return self.address.lower() == other.address.lower() return False + def __ne__(self, other): + """ + Negative comparison support + """ + return not (self == other) + + def __hash__(self): """ Hashing allows using Address objects as keys in collections and compare diff --git a/tests/addresslib/address_test.py b/tests/addresslib/address_test.py index 13088a4..cdbadec 100644 --- a/tests/addresslib/address_test.py +++ b/tests/addresslib/address_test.py @@ -46,6 +46,13 @@ def test_address_compare(): s.add(u) eq_(2, len(s)) + # test string comparison + ok_(a == a.address) + ok_(not (a != a.address)) + + ok_(b != a.address) + ok_(not (b == a.address)) + def test_local_url(): u = UrlAddress('http:///foo/bar')