def test_calls_dist_to_other_candidate_when_finding_candidates(self): counter = MutableFloat(0) def mock_dist_to_other_candidate_func(other_candidate): counter.increment(1) return 0 candidate = ClusterCandidate() candidate.distance_to_candidate = mock_dist_to_other_candidate_func candidate.find_neighbors([1, 2, 3, 4, 5], epsilon=0) self.assertEquals(counter.get_val(), 5)