def assert_dict_almost_equal(self, d1, d2, places=1):
        """Compare two dictionaries with numeric values allowing for small differences."""
        self.assertEqual(d1.keys(), d2.keys(), "Dictionaries have different keys")
        for key in d1:
            if isinstance(d1[key], dict):
                self.assert_dict_almost_equal(d1[key], d2[key], places)
            elif isinstance(d1[key], (int, float)) and isinstance(d2[key], (int, float)):
                self.assertAlmostEqual(d1[key], d2[key], places=places,
                                       msg=f"Values differ for key {key}: {d1[key]} != {d2[key]}")
            else:
                self.assertEqual(d1[key], d2[key],
                                 f"Values differ for key {key}: {d1[key]} != {d2[key]}")
Compare two dictionaries with numeric values allowing for small differences.
tests/api_tests/v1/tests/api_tests/unstructured_index/test_facets.py