diff --git a/keystoneauth1/loading/opts.py b/keystoneauth1/loading/opts.py index 5b4ecac7..b8f17590 100644 --- a/keystoneauth1/loading/opts.py +++ b/keystoneauth1/loading/opts.py @@ -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) diff --git a/keystoneauth1/tests/unit/loading/utils.py b/keystoneauth1/tests/unit/loading/utils.py index e8958085..c7c8de4e 100644 --- a/keystoneauth1/tests/unit/loading/utils.py +++ b/keystoneauth1/tests/unit/loading/utils.py @@ -76,6 +76,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') diff --git a/keystoneauth1/tests/unit/utils.py b/keystoneauth1/tests/unit/utils.py index 1aef9da3..0245b291 100644 --- a/keystoneauth1/tests/unit/utils.py +++ b/keystoneauth1/tests/unit/utils.py @@ -135,6 +135,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