py33: 'dict_keys' object does not support indexing
In python 3, dict.keys() is a class of 'dict_keys', it does not support indexing. Cast the dict to list to get the "first" value of dict, which is compatible with python 2&3. Closes-Bug: #1229005 Change-Id: I561b7ada9e5ad936659a657b3161a9b93a15a788
This commit is contained in:
parent
8deaf3769d
commit
f1c3b79c2b
novaclient
@ -206,7 +206,7 @@ def from_response(response, body, url, method=None):
|
||||
details = "n/a"
|
||||
|
||||
if hasattr(body, 'keys'):
|
||||
error = body[body.keys()[0]]
|
||||
error = body[list(body)[0]]
|
||||
message = error.get('message', None)
|
||||
details = error.get('details', None)
|
||||
|
||||
|
@ -113,7 +113,7 @@ class FakeHTTPClient(fakes.FakeHTTPClient):
|
||||
|
||||
def post_os_baremetal_nodes_1_action(self, **kw):
|
||||
body = kw['body']
|
||||
action = body.keys()[0]
|
||||
action = list(body)[0]
|
||||
if action == "add_interface":
|
||||
return (
|
||||
200, {}, {
|
||||
|
@ -488,7 +488,7 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
_body = None
|
||||
resp = 202
|
||||
assert len(body.keys()) == 1
|
||||
action = body.keys()[0]
|
||||
action = list(body)[0]
|
||||
if action == 'reboot':
|
||||
assert body[action].keys() == ['type']
|
||||
assert body[action]['type'] in ['HARD', 'SOFT']
|
||||
|
Loading…
x
Reference in New Issue
Block a user