Пример #1
0
 def test_divide_lambda_creates_single_element_subsets(self):
     e = Set({1, 3, 5, 7, 9})
     print(e.divide(lambda i, j: abs(i - j) == 1))
     expect(e.divide(lambda i, j: abs(i - j) == 1).to_set()).to(
         equal({Set({1}), Set({3}),
                Set({5}), Set({7}),
                Set({9})}))
Пример #2
0
 def test_eq_other_not_equal_both_enhanced_set(self):
     e = Set({1, 2, 3})
     o = Set({4, 5, 6})
     expect(e == o).to(be_false)
Пример #3
0
 def test_difference_if_other_subset_of_self_enhanced_set(self):
     e = Set({1, 2, 3, 4})
     o = Set({2, 3})
     expect(e.difference(o).to_set()).to(equal({1, 4}))
Пример #4
0
 def test_difference_if_other_equivalent_to_self(self):
     e = Set({1, 2, 3, 4})
     o = {1, 2, 3, 4}
     expect(e.difference(o).to_set()).to(equal(set()))
Пример #5
0
 def test_len_if_empty(self):
     e = Set()
     expect(len(e)).to(equal(0))
Пример #6
0
 def test_isdisjoint_if_param_is_different(self):
     e = Set({1, 2, 3})
     expect(e.isdisjoint('...')).to(be_false)
Пример #7
0
 def test_reject_if_lambda_find_match(self):
     e = Set({1, 2, 3, 4})
     expect(e.reject(lambda x: x % 2 == 0).to_set()).to(equal({1, 3}))
Пример #8
0
 def test_reject_if_lambda_finds_no_match(self):
     e = Set({1, 2, 3, 4})
     expect(e.reject(lambda x: x > 5).to_set()).to(equal({1, 2, 3, 4}))
Пример #9
0
 def test_and_other_is_different(self):
     e = Set({1, 2, 3})
     expect(lambda: e & None).to(raise_error(TypeError))
Пример #10
0
 def test_and_other_without_intersection(self):
     e = Set({1, 2, 3})
     expect((e & {4, 5, 6}).to_set()).to(equal(set()))
Пример #11
0
 def test_eq_other_not_equal(self):
     e = Set({1, 2, 3, 4})
     o = {3, 4, 5, 6}
     expect(e == o).to(be_false)
Пример #12
0
 def test_eq_other_is_different(self):
     e = Set({1, 2, 3})
     expect(e == 1).to(be_false)
Пример #13
0
 def test_eq_other_is_equal_with_enhanced_set(self):
     e = Set({1, 2, 3})
     o = Set({3, 2, 1})
     expect(e == o).to(be_true)
Пример #14
0
 def test_eq_other_is_equal(self):
     e = Set({1, 2, 3})
     o = {3, 2, 1}
     expect(e == o).to(be_false)
Пример #15
0
 def test_eq_other_greater_len(self):
     e = Set({1, 2, 3})
     o = {1, 2, 3, 4}
     expect(e == o).to(be_false)
Пример #16
0
 def test_add_if_set_is_empty(self):
     e = Set()
     expect(e.add(1).to_set()).to(equal({1}))
Пример #17
0
 def test_add_if_set_already_contains_element(self):
     e = Set({1, 2, 3, 4})
     expect(e.add(2).to_set()).to(equal({1, 2, 3, 4}))
Пример #18
0
 def test_and_other_with_inersection(self):
     e = Set({1, 2, 3, 4})
     o = {3, 4, 5, 6}
     expect((e & o).to_set()).to(equal({3, 4}))
Пример #19
0
 def test_reject_if_set_is_empty(self):
     e = Set({1, 2, 3})
     expect(lambda: e.reject('...')).to(raise_error(TypeError))
Пример #20
0
 def test_union_other_without_common_values(self):
     e = Set({1, 2, 3})
     o = Set({4, 5, 6})
     expect(e.union(o).to_set()).to(equal({1, 2, 3, 4, 5, 6}))
Пример #21
0
 def test_isdisjoint_if_disjoint(self):
     e = Set({1, 2, 3, 4})
     expect(e.isdisjoint(Set({5, 6, 7}))).to(be_true)
Пример #22
0
 def test_union_other_is_different(self):
     e = Set({1, 2, 3})
     expect(lambda: e.union(None)).to(raise_error(TypeError))
Пример #23
0
 def test_isdisjoint_if_have_intersection(self):
     e = Set({1, 2, 3, 4})
     expect(e.isdisjoint({1, 2, 7})).to(be_false)
Пример #24
0
 def test_union_other_with_common_values(self):
     e = Set({1, 2, 3, 4})
     o = Set({1, 2, 3, 4})
     expect(e.union(o)).to(equal(Set({1, 2, 3, 4})))
Пример #25
0
 def test_len_if_not_empty(self):
     e = Set({1, 2, 3, 4})
     expect(len(e)).to(equal(4))
Пример #26
0
 def test_str_if_self_contains_elements(self):
     e = Set({1, 2, 3, 4})
     expect(str(e)).to(equal('{1, 2, 3, 4}'))
Пример #27
0
 def test_difference_if_set_is_empty(self):
     e = Set()
     o = {1, 2}
     expect(e.difference(o).to_set()).to(equal(set()))
Пример #28
0
 def test_str_if_self_is_empty(self):
     e = Set()
     expect(str(e)).to(equal('{}'))
Пример #29
0
 def test_iter(self):
     it = iter(Set({1, 2, 3, 4}))
     expect(next(it)).to(equal(1))
     expect(next(it)).to(equal(2))
     expect(next(it)).to(equal(3))
     expect(next(it)).to(equal(4))
Пример #30
0
 def test_add_if_set_not_contains_element(self):
     e = Set({1, 2, 3, 4})
     expect(e.add(7).to_set()).to(equal({1, 2, 3, 4, 7}))