From 2b3b1792d5b72e6c0e499f9ecc2c4d2cf7ba65d6 Mon Sep 17 00:00:00 2001 From: howardlee <lihongweibj@inspur.com> Date: Wed, 16 Nov 2016 16:20:29 +0800 Subject: [PATCH] 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: I6adceadb6e3749e34cf847654f28a3b6eea832fd --- tackerclient/tests/unit/test_cli10.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tackerclient/tests/unit/test_cli10.py b/tackerclient/tests/unit/test_cli10.py index e88d641a..549c4fbe 100644 --- a/tackerclient/tests/unit/test_cli10.py +++ b/tackerclient/tests/unit/test_cli10.py @@ -169,6 +169,9 @@ class MyComparator(object): def __eq__(self, rhs): return self.equals(rhs) + def __ne__(self, rhs): + return not self.__eq__(rhs) + class CLITestV10Base(testtools.TestCase):