Revert "Add function helpers.compare_dict"

This reverts commit 34910dc074.

Change-Id: I113f120dba3c0ed7cbe1676f0a9fc8f1ba7ca2b9
This commit is contained in:
Rodolfo Alonso Hernandez 2018-12-21 15:40:05 +00:00
parent 34910dc074
commit 3b80a14bab
3 changed files with 0 additions and 42 deletions

View File

@ -90,19 +90,6 @@ class TestCompareElements(base.BaseTestCase):
['juve', 'napoli']))
class TestCompare(base.BaseTestCase):
def test_compare(self):
self.assertTrue(helpers.compare_dict({'a': 2}, {'a': 2}))
self.assertFalse(helpers.compare_dict({'a': 2}, {'a': 3}))
self.assertTrue(helpers.compare_dict({'a': [1, 2]}, {'a': [2, 1]}))
self.assertFalse(helpers.compare_dict({'a': [1, 2]}, {'a': [1]}))
self.assertTrue(helpers.compare_dict({'a': 'value1'}, {'a': 'value1'}))
self.assertFalse(helpers.compare_dict({'a': 'value'}, {'a': 'value1'}))
self.assertFalse(helpers.compare_dict({'a': '1'},
{'a': '1', 'b': '2'}))
class TestDictUtils(base.BaseTestCase):
def test_dict2str(self):

View File

@ -74,29 +74,6 @@ def compare_elements(a, b):
return set(a or []) == set(b or [])
def compare_dict(a, b):
"""Compare two dicts, including keys and values.
Useful because dict comparison was removed in Python 3.0.1.
:param a: The first dict to compare.
:param b: The second dict to compare.
:returns: True if a and b have the same keys and values, False otherwise.
"""
if sorted(list(a.keys())) != sorted(list(b.keys())):
return False
for key, value in a.items():
if not isinstance(value, type(b[key])):
return False
if isinstance(value, dict) and not compare_dict(value, b[key]):
return False
if isinstance(value, list) and not value.sort() == b[key].sort():
return False
elif value != b[key]:
return False
return True
def safe_sort_key(value):
"""Return value hash or build one for dictionaries.

View File

@ -1,6 +0,0 @@
---
features:
- |
Introduced ``compare_dict`` function in ``neutron_lib.utils.helpers``. It
allows you to compare two dictionaries, checking both the keys and the
values they contain.