def test_one_if_only_one_is_truthy(self): e = List([None, '', None, 0, False, ['apple'], None]) expect(e.one()).to(be_true)
def test_each_with_object_if_func_is_different(self): e = List([1, 2, 3, 4]) expect(lambda: e.each_with_object(object=[], callback=-1)).to( raise_error(TypeError))
def test_sort_if_list_is_empty(self): e = List([]) expect(e.sort(lambda x: len(x)).to_list()).to(equal([]))
def test_empty_if_list_is_not_empty(self): expect(List([1, 2, 3]).empty()).to(be_false)
def setUp(self): self.l = List([1, 2, 3, 2])
def test_group_by_if_param_is_lambda_create_one_key(self): e = List(['apple', 'bear', 'cat', 'anchor']) act = e.group_by(lambda x: 'a' in x) expect(act.get(True).sort()).to(equal(['apple', 'bear', 'cat', 'anchor'].sort())) expect(act.get(False)).to(equal(None))
def test_drop_while_if_param_is_different_raises_error(self): e = List([1, 2, 3, 4]) expect(lambda: e.drop_while('...')).to(raise_error(TypeError))
def test_none_if_all_of_them_are_falsy(self): e = List([None, '', None, 0, False, [], None]) expect(e.none()).to(be_true)
def test_none_if_list_is_empty(self): e = List([]) expect(e.none()).to(be_true)
def setUp(self): self.l = List()
def test_none_if_not_all_of_them_are_falsy(self): e = List([False, None, 'dog', 'plum']) expect(e.none()).to(be_false)
def test_one_if_all_of_them_are_truthy(self): e = List([5, 3, 5, 2, 4]) expect(e.one()).to(be_false)
def test_one_if_lambda_is_true_only_one(self): e = List(['apple', 'caterpillar', 'bear', 'dog', 'plum']) expect(e.one(lambda x: len(x) > 5)).to(be_true)
def test_one_if_list_is_empty(self): e = List([]) expect(e.one()).to(be_false)
def test_min_n_if_lambda_is_different(self): e = List(['apple', 'caterpillar', 'bear', 'dog', 'plum']) expect(lambda: e.min_n(2, '...')).to(raise_error(TypeError))
def test_none_if_lambda_is_false_on_all(self): e = List(['apple', 'caterpillar', 'bear', 'dog', 'plum']) expect(e.none(lambda x: len(x) > 15)).to(be_true)
def test_min_n_if_list_of_numbers(self): e = List([5, 3, 5, 2, 4]) expect(e.min_n(2).to_list()).to(equal([2, 3]))
def test_none_if_none_of_them_are_falsy(self): e = List([5, 3, 5, 2, 4]) expect(e.none()).to(be_false)
def test_group_by_if_param_is_non_regex_object_nor_string(self): e = List([1, 2, 3, 4, 5, 6]) expect(lambda: e.group_by(1)).to(raise_error(TypeError))
def test_min_n_if_list_of_string(self): e = List(['apple', 'bear', 'dog', 'plum']) expect(e.min_n(2).to_list()).to(equal(['apple', 'bear']))
def test_drop_while_if_param_is_lambda_and_finds_match(self): e = List([1, 2, 3, 4]) expect(e.drop_while(lambda x: x < 3).to_list()).to(equal([3, 4]))
def test_min_n_if_list_is_empty(self): e = List([]) expect(e.min_n(2).to_list()).to(equal([]))
def test_empty_if_list_is_empty(self): expect(List([]).empty()).to(be_true)
def test_min_n_if_list_is_empty_with_lambda(self): e = List([]) expect(e.min_n(2, lambda x: len(x)).to_list()).to(equal([]))
def test_each_with_object_if_param_is_string(self): e = List([1, 2, 3]) expect(e.each_with_object(object='a').to_list()).to( equal([[1, 'a'], [2, 'a'], [3, 'a']]))
def test_min_n_if_compare_with_lambda_len(self): e = List(['apple', 'caterpillar', 'bear', 'dog', 'plum']) expect(e.min_n(3, lambda x: len(x)).to_list()).to( equal(['dog', 'bear', 'plum']))
def test_each_with_object_if_param_is_array(self): e = List([1, 2, 3]) expect(e.each_with_object(object=[]).to_list()).to( equal([[1, []], [2, []], [3, []]]))
def test_min_n_if_compare_with_lambda_div(self): e = List([1, 2, 3, 4, 5, 6, 7]) expect(e.min_n(3, lambda x: x % 4).to_list()).to(equal([4, 1, 5]))
def test_sort_if_lambda_is_valid_len(self): e = List(['apple', 'caterpillar', 'bear', 'dog', 'plum']) expect(e.sort(lambda x: len(x)).to_list()).to( equal(['dog', 'bear', 'plum', 'apple', 'caterpillar']))
def test_one_if_more_than_one_is_truthy(self): e = List([False, None, 'dog', 'plum']) expect(e.one()).to(be_false)