[Python] Improve model equality implementation (#4663)

* [Python] Improve model equality implementation

The model equality implementation template blindly tried accessing the
`__dict__` attribute of the variable to compare equality against. This
attribute does not exist for a lot of Python built-in types (`None`,
`str` etc.) and the equality check would simply crash.

This adds a simple guard to only continue with equality check if the
variable to compare is an instance of the model being compared against.

* Remove wrong auto-update of Python requirements
This commit is contained in:
Frode Danielsen
2017-01-27 17:42:53 +01:00
committed by wing328
parent 869374125f
commit 3236ade09d
37 changed files with 104 additions and 5 deletions

View File

@@ -116,7 +116,7 @@ class ApiClient(object):
collection_formats)
for k, v in path_params:
resource_path = resource_path.replace(
'{%s}' % k, quote(str(v)))
'{%s}' % k, quote(str(v), safe=""))
# query parameters
if query_params:

View File

@@ -116,12 +116,9 @@ class FakeApi(object):
form_params.append(('test code inject */ ' " =end -- \r\n \n \r', params['test_code_inject____end____rn_n_r']))
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', '*/ \" =end -- '])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\

View File

@@ -105,6 +105,9 @@ class ModelReturn(object):
"""
Returns true if both objects are equal
"""
if not isinstance(other, ModelReturn):
return False
return self.__dict__ == other.__dict__
def __ne__(self, other):