Some classes not define __ne__() built-in function
Some classes defines __eq__() built-in function, but does not define __ne__() built-in function, so self.assertEqual works but self.assertNotEqual does not work at all in this test case in python2. This patch fixes it. Change-Id: I3e4f213081268bad44583a63a84795d39094117f Closes-Bug: #1586268
This commit is contained in:
parent
7ce20e80b7
commit
e26f09e0d1
|
@ -67,6 +67,9 @@ class TopicWorker(object):
|
|||
else:
|
||||
return other.identity == self.identity
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __repr__(self):
|
||||
r = reflection.get_class_name(self, fully_qualified=False)
|
||||
if self.identity is not self._NO_IDENTITY:
|
||||
|
|
|
@ -156,6 +156,9 @@ class RedisJob(base.Job):
|
|||
return ((self.board.listings_key, self.priority, self.sequence) ==
|
||||
(other.board.listings_key, other.priority, other.sequence))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __hash__(self):
|
||||
return hash((self.board.listings_key, self.priority, self.sequence))
|
||||
|
||||
|
|
|
@ -201,6 +201,9 @@ class ZookeeperJob(base.Job):
|
|||
return ((self.root, self.sequence, self.priority) ==
|
||||
(other.root, other.sequence, other.priority))
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def __hash__(self):
|
||||
return hash(self.path)
|
||||
|
||||
|
|
|
@ -231,6 +231,9 @@ class _Provider(object):
|
|||
def __eq__(self, other):
|
||||
return (self.name, self.index) == (other.name, other.index)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
def _item_from(container, index):
|
||||
"""Attempts to fetch a index/key from a given container."""
|
||||
|
|
|
@ -375,6 +375,9 @@ class FailureMatcher(object):
|
|||
def __eq__(self, other):
|
||||
return self._failure.matches(other)
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
class OneReturnRetry(retry.AlwaysRevert):
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ class Listener(object):
|
|||
else:
|
||||
return NotImplemented
|
||||
|
||||
def __ne__(self, other):
|
||||
return not self.__eq__(other)
|
||||
|
||||
|
||||
class Notifier(object):
|
||||
"""A notification (`pub/sub`_ *like*) helper class.
|
||||
|
|
Loading…
Reference in New Issue