From: Tomas Babej Date: Sun, 22 May 2016 13:59:06 +0000 (+0200) Subject: Merge pull request #45 from sarg/develop X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/dee3ee71ea684e5b4414c39aa93e14df6596c2ef?hp=d0dcd579031070fca1a8138b86af24c538f7f6d0 Merge pull request #45 from sarg/develop add __ne__ methods for python2 compatibility --- diff --git a/tasklib/lazy.py b/tasklib/lazy.py index a1b63ef..f9e0c0a 100644 --- a/tasklib/lazy.py +++ b/tasklib/lazy.py @@ -36,6 +36,9 @@ class LazyUUIDTask(object): # For saved Tasks, just define equality by equality of uuids return self['uuid'] == other['uuid'] + def __ne__(self, other): + return not self.__eq__(other) + def __hash__(self): return self['uuid'].__hash__() diff --git a/tasklib/task.py b/tasklib/task.py index 5eabc65..57b7338 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -165,6 +165,9 @@ class TaskAnnotation(TaskResource): # their data dics are the same return self.task == other.task and self._data == other._data + def __ne__(self, other): + return not self.__eq__(other) + __repr__ = __unicode__ @@ -277,6 +280,9 @@ class Task(TaskResource): # If the tasks are not saved, compare the actual instances return id(self) == id(other) + def __ne__(self, other): + return not self.__eq__(other) + def __hash__(self): if self['uuid']: # For saved Tasks, just define equality by equality of uuids diff --git a/tasklib/tests.py b/tasklib/tests.py index be54504..af873e1 100644 --- a/tasklib/tests.py +++ b/tasklib/tests.py @@ -1165,6 +1165,7 @@ class LazyUUIDTaskTest(TasklibTest): def test_normal_to_lazy_equality(self): assert self.stored == self.lazy + assert not self.stored != self.lazy assert type(self.lazy) is LazyUUIDTask def test_lazy_to_lazy_equality(self): @@ -1172,6 +1173,7 @@ class LazyUUIDTaskTest(TasklibTest): lazy2 = LazyUUIDTask(self.tw, self.stored['uuid']) assert lazy1 == lazy2 + assert not lazy1 != lazy2 assert type(lazy1) is LazyUUIDTask assert type(lazy2) is LazyUUIDTask