diff options
author | yuyafei <yu.yafei@zte.com.cn> | 2016-07-05 15:04:24 +0800 |
---|---|---|
committer | yuyafei <yu.yafei@zte.com.cn> | 2016-07-07 11:28:23 +0800 |
commit | de51a6db36bcd965a7fa7505380100497ae3c66a (patch) | |
tree | 655168d3d28cf5ac006d9cacdd593918937d1e75 | |
parent | 9045f338693474303f209a4909bca64031afbe9d (diff) | |
download | swift-de51a6db36bcd965a7fa7505380100497ae3c66a.tar.gz |
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__
Also remove class SubStringMatcher becasue this class isn't used
following commit 7035639dfd239b52d4ed46aae50f78d16ec8cbfe.
Change-Id: Ia2131f72a79226b0c2f3662b84661eb870d1d692
-rw-r--r-- | swift/common/manager.py | 3 | ||||
-rw-r--r-- | test/unit/common/ring/test_builder.py | 7 |
2 files changed, 3 insertions, 7 deletions
diff --git a/swift/common/manager.py b/swift/common/manager.py index 2cc764493..bd499de69 100644 --- a/swift/common/manager.py +++ b/swift/common/manager.py @@ -441,6 +441,9 @@ class Server(object): except AttributeError: return False + def __ne__(self, other): + return not self.__eq__(other) + def get_pid_file_name(self, conf_file): """Translate conf_file to a corresponding pid_file diff --git a/test/unit/common/ring/test_builder.py b/test/unit/common/ring/test_builder.py index bdcd96f76..0ced59274 100644 --- a/test/unit/common/ring/test_builder.py +++ b/test/unit/common/ring/test_builder.py @@ -2154,13 +2154,6 @@ class TestRingBuilder(unittest.TestCase): # now double up a device assignment rb._replica2part2dev[1][200] = rb._replica2part2dev[2][200] - class SubStringMatcher(object): - def __init__(self, substr): - self.substr = substr - - def __eq__(self, other): - return self.substr in other - with self.assertRaises(exceptions.RingValidationError) as e: rb.validate() |