diff --git a/tests/voq/test_voq_ipfwd.py b/tests/voq/test_voq_ipfwd.py index 03a55e73130..4f79641861c 100644 --- a/tests/voq/test_voq_ipfwd.py +++ b/tests/voq/test_voq_ipfwd.py @@ -579,9 +579,13 @@ def test_host_route_table_nbr_lb_addr(self, duthosts, enum_rand_one_per_hwsku_fr neighs = cfg_facts['BGP_NEIGHBOR'] # Remove the neighbor if BGP neighbor is of type RegionalHub + keys_to_remove = [] for k, v in neighs.items(): if v['name'] in dev_rh_neigh: - neighs.pop(k) + keys_to_remove.append(k) + + for k in keys_to_remove: + neighs.pop(k) for neighbor in neighs: local_ip = neighs[neighbor]['local_addr']