示例#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}))