summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-21 01:24:06 +0000
committerGerrit Code Review <review@openstack.org>2016-12-21 01:24:06 +0000
commit084b0abb755ac36415058f485fc6b0f318d9c041 (patch)
treec2c0c3101448a6e0e3cca4d0184e770ada3ffb7b
parent0b253a8dce0ed5686dd80fb8352eec9892b67a48 (diff)
parent78e621faf757e3bf4bd8475c29090bb1c83bc0cd (diff)
downloadpython-novaclient-084b0abb755ac36415058f485fc6b0f318d9c041.tar.gz
Merge "Fixed the __ne__ implementation in base.Resource"
-rw-r--r--novaclient/base.py4
-rw-r--r--novaclient/tests/unit/test_base.py6
2 files changed, 9 insertions, 1 deletions
diff --git a/novaclient/base.py b/novaclient/base.py
index 2d08cf27..6bcb527c 100644
--- a/novaclient/base.py
+++ b/novaclient/base.py
@@ -210,7 +210,9 @@ class Resource(RequestIdMixin):
return self._info == other._info
def __ne__(self, other):
- return not self.__eq__(other)
+ # Using not of '==' implementation because the not of
+ # __eq__, when it returns NotImplemented, is returning False.
+ return not self == other
def is_loaded(self):
return self._loaded
diff --git a/novaclient/tests/unit/test_base.py b/novaclient/tests/unit/test_base.py
index 74ceca39..eb70dff9 100644
--- a/novaclient/tests/unit/test_base.py
+++ b/novaclient/tests/unit/test_base.py
@@ -71,6 +71,12 @@ class BaseTest(utils.TestCase):
r2 = base.Resource(None, {'name': 'joe', 'age': 12})
self.assertEqual(r1, r2)
+ def test_ne(self):
+ # Two resources of different types: never equal
+ r1 = base.Resource(None, {'id': 1, 'name': 'test'})
+ r2 = object()
+ self.assertNotEqual(r1, r2)
+
def test_findall_invalid_attribute(self):
cs = fakes.FakeClient(api_versions.APIVersion("2.0"))
# Make sure findall with an invalid attribute doesn't cause errors.