def test_unique(): """ This should add the unique values of itr to unique_list. """ itr = [6, 1, 2, 1, 7, 41.2, '41.2', 1, '41.2'] unique_list = [] for elem in util.unique(itr): unique_list.append(elem) assert unique_list == [6, 1, 2, 7, 41.2, '41.2']
def test_unique_key(): """ This should add each element of itr to unique_list if no preceding element is congruent to it in mod 10. """ itr = [7, 3, 17, 104, 6, 1006, 117, 14, 10] unique_list = [] for elem in util.unique(itr, lambda x: x % 10): unique_list.append(elem) assert unique_list == [7, 3, 104, 6, 10]
def _merge(self, responses): """ Implementation detail. """ return list(unique(chain.from_iterable(responses), _freeze))
def merge(self, responses): return list(unique(chain.from_iterable(responses), _freeze))