Merge "Add __ne__ built-in function"

This commit is contained in:
Jenkins 2017-01-06 18:12:48 +00:00 committed by Gerrit Code Review
commit f387043138
3 changed files with 18 additions and 0 deletions

View File

@ -125,6 +125,12 @@ class Opt(object):
self.default == other.default and
self.metavar == other.metavar)
# NOTE: This function is only needed by Python 2. If we get to point where
# we don't support Python 2 anymore, this function should be removed.
def __ne__(self, other):
"""Define inequality operator on option parameters."""
return not self.__eq__(other)
@property
def _all_opts(self):
return itertools.chain([self], self.deprecated)

View File

@ -75,6 +75,12 @@ class BoolType(object):
# hack around oslo.config equality comparison
return type(self) == type(other)
# NOTE: This function is only needed by Python 2. If we get to point where
# we don't support Python 2 anymore, this function should be removed.
def __ne__(self, other):
"""Define inequiality for many bool types."""
return not self.__eq__(other)
def __call__(self, value):
return str(value).lower() in ('1', 'true', 't', 'yes', 'y')

View File

@ -134,6 +134,12 @@ class TestResponse(requests.Response):
"""Define equiality behavior of request and response."""
return self.__dict__ == other.__dict__
# NOTE: This function is only needed by Python 2. If we get to point where
# we don't support Python 2 anymore, this function should be removed.
def __ne__(self, other):
"""Define inequiality behavior of request and response."""
return not self.__eq__(other)
@property
def text(self):
return self.content