Class Credentials not define __ne__() built-in function

Class Credentials 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.

Change-Id: I2c0d9d6202d64de57700ceb7c15db8ed3ad7e8ff
Closes-Bug: #1586268
This commit is contained in:
Ji-Wei 2016-07-14 16:58:43 +08:00 committed by JiWei
parent 22afc4b8ec
commit 79f5efd468
1 changed files with 4 additions and 0 deletions

View File

@ -689,6 +689,10 @@ class Credentials(object):
"""Credentials are equal if attributes in self.ATTRIBUTES are equal""" """Credentials are equal if attributes in self.ATTRIBUTES are equal"""
return str(self) == str(other) return str(self) == str(other)
def __ne__(self, other):
"""Contrary to the __eq__"""
return not self.__eq__(other)
def __getattr__(self, key): def __getattr__(self, key):
# If an attribute is set, __getattr__ is not invoked # If an attribute is set, __getattr__ is not invoked
# If an attribute is not set, and it is a known one, return None # If an attribute is not set, and it is a known one, return None