[entity] comparing two entities returns NotImplemented
authorJulien Cristau <julien.cristau@logilab.fr>
Thu, 25 Feb 2016 09:28:21 +0100
changeset 11167 e7514e949ad8
parent 11166 81fce01b4cc0
child 11168 dfa5f8879e8f
[entity] comparing two entities returns NotImplemented Fixes a test when using some versions of unittest2, where assertItemsEqual tries a sort and expects TypeError, which it doesn't get if we directly raise NotImplementedError. The NotImplemented value is treated specially by the interpreter: https://docs.python.org/3.4/library/constants.html#NotImplemented
cubicweb/entity.py
--- a/cubicweb/entity.py	Thu Feb 18 09:24:43 2016 +0100
+++ b/cubicweb/entity.py	Thu Feb 25 09:28:21 2016 +0100
@@ -547,7 +547,7 @@
             self.e_schema, self.eid, list(self.cw_attr_cache), id(self))
 
     def __lt__(self, other):
-        raise NotImplementedError('comparison not implemented for %s' % self.__class__)
+        return NotImplemented
 
     def __eq__(self, other):
         if isinstance(self.eid, integer_types):