summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJi-Wei <ji.wei3@zte.com.cn>2016-08-31 18:23:25 +0800
committerJiWei <ji.wei3@zte.com.cn>2016-08-31 10:57:50 +0000
commite26f09e0d14d7a1a763596dd8a6029237e5ce530 (patch)
treed596b37a634cdc623825ef2540a5fee5454016fe
parent7ce20e80b74c70793957e18032d7d6293a01091c (diff)
downloadtaskflow-e26f09e0d14d7a1a763596dd8a6029237e5ce530.tar.gz
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
-rw-r--r--taskflow/engines/worker_based/types.py3
-rw-r--r--taskflow/jobs/backends/impl_redis.py3
-rw-r--r--taskflow/jobs/backends/impl_zookeeper.py3
-rw-r--r--taskflow/storage.py3
-rw-r--r--taskflow/tests/utils.py3
-rw-r--r--taskflow/types/notifier.py3
6 files changed, 18 insertions, 0 deletions
diff --git a/taskflow/engines/worker_based/types.py b/taskflow/engines/worker_based/types.py
index 9b660b5..b2334a3 100644
--- a/taskflow/engines/worker_based/types.py
+++ b/taskflow/engines/worker_based/types.py
@@ -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:
diff --git a/taskflow/jobs/backends/impl_redis.py b/taskflow/jobs/backends/impl_redis.py
index e24c174..cd141e2 100644
--- a/taskflow/jobs/backends/impl_redis.py
+++ b/taskflow/jobs/backends/impl_redis.py
@@ -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))
diff --git a/taskflow/jobs/backends/impl_zookeeper.py b/taskflow/jobs/backends/impl_zookeeper.py
index 5a446cb..3c83d8a 100644
--- a/taskflow/jobs/backends/impl_zookeeper.py
+++ b/taskflow/jobs/backends/impl_zookeeper.py
@@ -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)
diff --git a/taskflow/storage.py b/taskflow/storage.py
index 15edb19..be52774 100644
--- a/taskflow/storage.py
+++ b/taskflow/storage.py
@@ -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."""
diff --git a/taskflow/tests/utils.py b/taskflow/tests/utils.py
index ed4d4e9..471da9b 100644
--- a/taskflow/tests/utils.py
+++ b/taskflow/tests/utils.py
@@ -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):
diff --git a/taskflow/types/notifier.py b/taskflow/types/notifier.py
index b81d255..c91cea1 100644
--- a/taskflow/types/notifier.py
+++ b/taskflow/types/notifier.py
@@ -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.