From fd1cb1d9cffba7a0683f8f25ed3766e2c2885099 Mon Sep 17 00:00:00 2001 From: poojajadhav Date: Tue, 7 Mar 2017 15:20:26 +0530 Subject: [PATCH] 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 --- masakariclient/common/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/masakariclient/common/utils.py b/masakariclient/common/utils.py index 9cd92c4..5f8974b 100644 --- a/masakariclient/common/utils.py +++ b/masakariclient/common/utils.py @@ -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