Remove None for dict.get()
Because If no default value is specified it defaults to None already. Change-Id: I3caad9f17840347e30465c7bd4c9c4fe53d991e3
This commit is contained in:
parent
7cf73f1942
commit
ca721d6e9b
@ -222,8 +222,8 @@ def from_response(response, body, url, method=None):
|
||||
|
||||
if hasattr(body, 'keys'):
|
||||
error = body[list(body)[0]]
|
||||
message = error.get('message', None)
|
||||
details = error.get('details', None)
|
||||
message = error.get('message')
|
||||
details = error.get('details')
|
||||
|
||||
kwargs['message'] = message
|
||||
kwargs['details'] = details
|
||||
|
@ -422,8 +422,8 @@ def from_response(response, method, url):
|
||||
else:
|
||||
if hasattr(body, "keys"):
|
||||
error = body[body.keys()[0]]
|
||||
kwargs["message"] = error.get("message", None)
|
||||
kwargs["details"] = error.get("details", None)
|
||||
kwargs["message"] = error.get("message")
|
||||
kwargs["details"] = error.get("details")
|
||||
elif content_type.startswith("text/"):
|
||||
kwargs["details"] = response.text
|
||||
|
||||
|
@ -84,7 +84,7 @@ def env(*args, **kwargs):
|
||||
If all are empty, defaults to '' or keyword arg `default`.
|
||||
"""
|
||||
for arg in args:
|
||||
value = os.environ.get(arg, None)
|
||||
value = os.environ.get(arg)
|
||||
if value:
|
||||
return value
|
||||
return kwargs.get('default', '')
|
||||
|
@ -45,10 +45,10 @@ class TestResponse(requests.Response):
|
||||
super(TestResponse, self).__init__()
|
||||
self._text = None
|
||||
if isinstance(data, dict):
|
||||
self.status_code = data.get('status_code', None)
|
||||
self.headers = data.get('headers', None)
|
||||
self.status_code = data.get('status_code')
|
||||
self.headers = data.get('headers')
|
||||
# Fake the text attribute to streamline Response creation
|
||||
self._text = data.get('text', None)
|
||||
self._text = data.get('text')
|
||||
else:
|
||||
self.status_code = data
|
||||
|
||||
|
@ -79,7 +79,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
(method, url, callback))
|
||||
|
||||
# Note the call
|
||||
self.callstack.append((method, url, kwargs.get('body', None)))
|
||||
self.callstack.append((method, url, kwargs.get('body')))
|
||||
|
||||
status, headers, body = getattr(self, callback)(**kwargs)
|
||||
r = utils.TestResponse({
|
||||
|
@ -31,9 +31,9 @@ class FlavorAccessManager(base.ManagerWithFind):
|
||||
resource_class = FlavorAccess
|
||||
|
||||
def list(self, **kwargs):
|
||||
if kwargs.get('flavor', None):
|
||||
if kwargs.get('flavor'):
|
||||
return self._list_by_flavor(kwargs['flavor'])
|
||||
elif kwargs.get('tenant', None):
|
||||
elif kwargs.get('tenant'):
|
||||
return self._list_by_tenant(kwargs['tenant'])
|
||||
else:
|
||||
raise NotImplementedError(_('Unknown list options.'))
|
||||
|
Loading…
Reference in New Issue
Block a user