]> khamidou — GitHub mirrors - flanker.git/commitdiff
fix bug with != operator against a string
authorAndrew Roberts <andrew.roberts@parlai.com>
Fri, 23 Jan 2015 17:24:01 +0000 (12:24 -0500)
committerAndrew Roberts <andrew.roberts@parlai.com>
Fri, 23 Jan 2015 17:24:01 +0000 (12:24 -0500)
flanker/addresslib/address.py
tests/addresslib/address_test.py

index 6fb098d7736b5995427155e8ee00707015434fb0..a183a7815299c65c984e2d2a7adc79249cf6e951 100644 (file)
@@ -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
index 13088a42fc7da20b6c4b13d6dc9751b0bd730846..cdbadec0859b1fadceb06f299847453c939d0aa1 100644 (file)
@@ -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')