From 55201c55a8d74fc49fe8e6359d54d5b4c2303e1c Mon Sep 17 00:00:00 2001 From: yuyafei Date: Mon, 4 Jul 2016 15:30:56 +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: I39e6f6b94e9490afc14143208e6f20b0ef960991 Closes-Bug: #1586268 --- novaclient/base.py | 3 +++ novaclient/tests/unit/test_base.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/novaclient/base.py b/novaclient/base.py index 0200332d6..6ef271684 100644 --- a/novaclient/base.py +++ b/novaclient/base.py @@ -209,6 +209,9 @@ class Resource(RequestIdMixin): return self.id == other.id return self._info == other._info + def __ne__(self, other): + return not self.__eq__(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 9fa75364c..a24636ca5 100644 --- a/novaclient/tests/unit/test_base.py +++ b/novaclient/tests/unit/test_base.py @@ -63,7 +63,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 = flavors.Flavor(None, {'id': 1}) self.assertNotEqual(r1, r2)