From ccde9b3ba78e2dd0f2a726e6d23dba91f8ee061f Mon Sep 17 00:00:00 2001 From: yuyafei Date: Sat, 28 May 2016 16:10:15 +0800 Subject: [PATCH] base.Resource not define __ne__() built-in function Class base.Resource defines __eq__() built-in function, but does not define __ne__() built-in function, so self.assertEqual works but self.assertNotEqual does not work at all in this test case in python2. This patch fixes it by defining __ne__() built-in function of class base.Resource. Also fixes spelling errors:resoruces. Change-Id: I845d531880ad74d928a3e15335ed10e71590826e Closes-Bug: #1586268 --- cinderclient/openstack/common/apiclient/base.py | 3 +++ cinderclient/tests/unit/test_base.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cinderclient/openstack/common/apiclient/base.py b/cinderclient/openstack/common/apiclient/base.py index 619af93..2503898 100644 --- a/cinderclient/openstack/common/apiclient/base.py +++ b/cinderclient/openstack/common/apiclient/base.py @@ -524,6 +524,9 @@ class Resource(RequestIdMixin): return False return self._info == other._info + def __ne__(self, other): + return not self.__eq__(other) + def is_loaded(self): return self._loaded diff --git a/cinderclient/tests/unit/test_base.py b/cinderclient/tests/unit/test_base.py index 48ec60b..437ff2e 100644 --- a/cinderclient/tests/unit/test_base.py +++ b/cinderclient/tests/unit/test_base.py @@ -58,7 +58,7 @@ class BaseTest(utils.TestCase): r2 = base.Resource(None, {'id': 1, 'name': 'hello'}) self.assertEqual(r1, r2) - # Two resoruces of different types: never equal + # Two resources of different types: never equal r1 = base.Resource(None, {'id': 1}) r2 = volumes.Volume(None, {'id': 1}) self.assertNotEqual(r1, r2)