diff --git a/kombu/entity.py b/kombu/entity.py index e1d62b43..189c9de3 100644 --- a/kombu/entity.py +++ b/kombu/entity.py @@ -271,7 +271,10 @@ class Exchange(MaybeChannelBound): self.durable == other.durable and self.auto_delete == other.auto_delete and self.delivery_mode == other.delivery_mode) - return False + return NotImplemented + + def __ne__(self, other): + return not self.__eq__(other) def __repr__(self): return super(Exchange, self).__repr__(str(self)) @@ -642,7 +645,10 @@ class Queue(MaybeChannelBound): self.durable == other.durable and self.exclusive == other.exclusive and self.auto_delete == other.auto_delete) - return False + return NotImplemented + + def __ne__(self, other): + return not self.__eq__(other) def __repr__(self): s = super(Queue, self).__repr__ diff --git a/kombu/tests/test_entities.py b/kombu/tests/test_entities.py index 21dcb35d..3fbb5b89 100644 --- a/kombu/tests/test_entities.py +++ b/kombu/tests/test_entities.py @@ -94,7 +94,7 @@ class test_Exchange(TestCase): e3 = Exchange('foo', 'topic') self.assertNotEqual(e1, e3) - self.assertFalse(e1.__eq__(True)) + self.assertEqual(e1.__eq__(True), NotImplemented) def test_revive(self): exchange = Exchange('foo', 'direct') @@ -264,7 +264,7 @@ class test_Queue(TestCase): q1 = Queue('xxx', Exchange('xxx', 'direct'), 'xxx') q2 = Queue('xxx', Exchange('xxx', 'direct'), 'xxx') self.assertEqual(q1, q2) - self.assertFalse(q1.__eq__(True)) + self.assertEqual(q1.__eq__(True), NotImplemented) q3 = Queue('yyy', Exchange('xxx', 'direct'), 'xxx') self.assertNotEqual(q1, q3) diff --git a/kombu/utils/functional.py b/kombu/utils/functional.py index 49a7c6d2..374bf356 100644 --- a/kombu/utils/functional.py +++ b/kombu/utils/functional.py @@ -38,6 +38,9 @@ class promise(object): def __eq__(self, rhs): return self() == rhs + def __ne__(self, rhs): + return self() != rhs + def __deepcopy__(self, memo): memo[id(self)] = self return self