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: I9eb823d25d3b119653f31718056576dbc59b6960
This commit is contained in:
parent
cf2c9fca49
commit
22c627abaf
|
@ -77,3 +77,6 @@ class SubDictMatch(object):
|
|||
def __eq__(self, super_dict):
|
||||
return all(item in super_dict.items()
|
||||
for item in self.sub_dict.items())
|
||||
|
||||
def __ne__(self, super_dict):
|
||||
return not self.__eq__(super_dict)
|
||||
|
|
Loading…
Reference in New Issue