Пример #1
0
 def test_one_if_only_one_is_truthy(self):
     e = List([None, '', None, 0, False, ['apple'], None])
     expect(e.one()).to(be_true)
Пример #2
0
 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))
Пример #3
0
 def test_sort_if_list_is_empty(self):
     e = List([])
     expect(e.sort(lambda x: len(x)).to_list()).to(equal([]))
Пример #4
0
 def test_empty_if_list_is_not_empty(self):
     expect(List([1, 2, 3]).empty()).to(be_false)
Пример #5
0
 def setUp(self):
     self.l = List([1, 2, 3, 2])
Пример #6
0
 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))
Пример #7
0
 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))
Пример #8
0
 def test_none_if_all_of_them_are_falsy(self):
     e = List([None, '', None, 0, False, [], None])
     expect(e.none()).to(be_true)
Пример #9
0
 def test_none_if_list_is_empty(self):
     e = List([])
     expect(e.none()).to(be_true)
Пример #10
0
 def setUp(self):
     self.l = List()
Пример #11
0
 def test_none_if_not_all_of_them_are_falsy(self):
     e = List([False, None, 'dog', 'plum'])
     expect(e.none()).to(be_false)
Пример #12
0
 def test_one_if_all_of_them_are_truthy(self):
     e = List([5, 3, 5, 2, 4])
     expect(e.one()).to(be_false)
Пример #13
0
 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)
Пример #14
0
 def test_one_if_list_is_empty(self):
     e = List([])
     expect(e.one()).to(be_false)
Пример #15
0
 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))
Пример #16
0
 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)
Пример #17
0
 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]))
Пример #18
0
 def test_none_if_none_of_them_are_falsy(self):
     e = List([5, 3, 5, 2, 4])
     expect(e.none()).to(be_false)
Пример #19
0
 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))
Пример #20
0
 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']))
Пример #21
0
 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]))
Пример #22
0
 def test_min_n_if_list_is_empty(self):
     e = List([])
     expect(e.min_n(2).to_list()).to(equal([]))
Пример #23
0
 def test_empty_if_list_is_empty(self):
     expect(List([]).empty()).to(be_true)
Пример #24
0
 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([]))
Пример #25
0
 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']]))
Пример #26
0
 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']))
Пример #27
0
 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, []]]))
Пример #28
0
 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]))
Пример #29
0
 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']))
Пример #30
0
 def test_one_if_more_than_one_is_truthy(self):
     e = List([False, None, 'dog', 'plum'])
     expect(e.one()).to(be_false)