Fix failing test case for PY3

On current master code test case failing on Python 3.x and gives
following error: RuntimeError as dictionary changed size during
iteration.

In Python 2.x calling items makes a copy of the items that you can
iterate over while modifying the dict. This doesn't work in Python
3.x because items returns an iterator instead of a list.

To fix this issue forced a copy of the items to be made by using
list() method.

NOTE:
Currently we don't have gate job for python3.x so this issue can
not be reproduced on gate.

Change-Id: If6ec61c735de71be21c0a55a1b165941ae5ac1a0
This commit is contained in:
poojajadhav 2017-03-07 15:20:26 +05:30
parent 8615148918
commit fd1cb1d9cf
1 changed files with 1 additions and 1 deletions

View File

@ -57,7 +57,7 @@ def format_parameters(params, parse_semicolon=True):
def remove_unspecified_items(attrs):
"""Remove the items that don't have any values."""
for key, value in attrs.items():
for key, value in list(attrs.items()):
if not value:
del attrs[key]
return attrs