Skip to content

Commit d65d331

Browse files
committed
Add __ne__ built-in function
In Python 3 __ne__ by default delegates to __eq__ and inverts the result, but in Python 2 they urge you to define __ne__ when you define __eq__ for it to work properly [1].There are no implied relationships among the comparison operators. The truth of x==y does not imply that x!=y is false. Accordingly, when defining __eq__(), one should also define __ne__() so that the operators will behave as expected. [1]https://docs.python.org/2/reference/datamodel.html#object.__ne_ Change-Id: I4ba5b370e34cd64b13d87ef3ce2869d224dd0969
1 parent c1141ed commit d65d331

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ceilometerclient/apiclient/fake_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def __eq__(self, other):
8787
self.headers == other.headers and
8888
self._content == other._content)
8989

90+
def __ne__(self, other):
91+
return not self.__eq__(other)
92+
9093

9194
class FakeHTTPClient(client.HTTPClient):
9295

0 commit comments

Comments
 (0)