diff --git a/neutron_lib/tests/unit/utils/test_helpers.py b/neutron_lib/tests/unit/utils/test_helpers.py index 1318c36a5..4e7b0503f 100644 --- a/neutron_lib/tests/unit/utils/test_helpers.py +++ b/neutron_lib/tests/unit/utils/test_helpers.py @@ -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): diff --git a/neutron_lib/utils/helpers.py b/neutron_lib/utils/helpers.py index 3b921e1e3..5f999c972 100644 --- a/neutron_lib/utils/helpers.py +++ b/neutron_lib/utils/helpers.py @@ -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. diff --git a/releasenotes/notes/add-compare-dict-315a66a65cbce6fd.yaml b/releasenotes/notes/add-compare-dict-315a66a65cbce6fd.yaml deleted file mode 100644 index 476e758fa..000000000 --- a/releasenotes/notes/add-compare-dict-315a66a65cbce6fd.yaml +++ /dev/null @@ -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.