diff options
author | gecong1973 <ge.cong@zte.com.cn> | 2016-11-23 15:10:56 +0800 |
---|---|---|
committer | gecong1973 <ge.cong@zte.com.cn> | 2016-11-23 15:10:56 +0800 |
commit | d65d3312e6fb8dc752741c46cf5796f22497c593 (patch) | |
tree | d6086c0493df5e2e31c6371124e884bc069b5176 | |
parent | c1141ed5be72ee169a7640b5d4957bfe02ad37ce (diff) | |
download | python-ceilometerclient-d65d3312e6fb8dc752741c46cf5796f22497c593.tar.gz |
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
-rw-r--r-- | ceilometerclient/apiclient/fake_client.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ceilometerclient/apiclient/fake_client.py b/ceilometerclient/apiclient/fake_client.py index 30a0731..d897cc5 100644 --- a/ceilometerclient/apiclient/fake_client.py +++ b/ceilometerclient/apiclient/fake_client.py @@ -87,6 +87,9 @@ class TestResponse(requests.Response): self.headers == other.headers and self._content == other._content) + def __ne__(self, other): + return not self.__eq__(other) + class FakeHTTPClient(client.HTTPClient): |