Ejemplo n.º 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})}))
Ejemplo n.º 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)
Ejemplo n.º 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}))
Ejemplo n.º 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()))
Ejemplo n.º 5
0
 def test_len_if_empty(self):
     e = Set()
     expect(len(e)).to(equal(0))
Ejemplo n.º 6
0
 def test_isdisjoint_if_param_is_different(self):
     e = Set({1, 2, 3})
     expect(e.isdisjoint('...')).to(be_false)
Ejemplo n.º 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}))
Ejemplo n.º 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}))
Ejemplo n.º 9
0
 def test_and_other_is_different(self):
     e = Set({1, 2, 3})
     expect(lambda: e & None).to(raise_error(TypeError))
Ejemplo n.º 10
0
 def test_and_other_without_intersection(self):
     e = Set({1, 2, 3})
     expect((e & {4, 5, 6}).to_set()).to(equal(set()))
Ejemplo n.º 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)
Ejemplo n.º 12
0
 def test_eq_other_is_different(self):
     e = Set({1, 2, 3})
     expect(e == 1).to(be_false)
Ejemplo n.º 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)
Ejemplo n.º 14
0
 def test_eq_other_is_equal(self):
     e = Set({1, 2, 3})
     o = {3, 2, 1}
     expect(e == o).to(be_false)
Ejemplo n.º 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)
Ejemplo n.º 16
0
 def test_add_if_set_is_empty(self):
     e = Set()
     expect(e.add(1).to_set()).to(equal({1}))
Ejemplo n.º 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}))
Ejemplo n.º 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}))
Ejemplo n.º 19
0
 def test_reject_if_set_is_empty(self):
     e = Set({1, 2, 3})
     expect(lambda: e.reject('...')).to(raise_error(TypeError))
Ejemplo n.º 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}))
Ejemplo n.º 21
0
 def test_isdisjoint_if_disjoint(self):
     e = Set({1, 2, 3, 4})
     expect(e.isdisjoint(Set({5, 6, 7}))).to(be_true)
Ejemplo n.º 22
0
 def test_union_other_is_different(self):
     e = Set({1, 2, 3})
     expect(lambda: e.union(None)).to(raise_error(TypeError))
Ejemplo n.º 23
0
 def test_isdisjoint_if_have_intersection(self):
     e = Set({1, 2, 3, 4})
     expect(e.isdisjoint({1, 2, 7})).to(be_false)
Ejemplo n.º 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})))
Ejemplo n.º 25
0
 def test_len_if_not_empty(self):
     e = Set({1, 2, 3, 4})
     expect(len(e)).to(equal(4))
Ejemplo n.º 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}'))
Ejemplo n.º 27
0
 def test_difference_if_set_is_empty(self):
     e = Set()
     o = {1, 2}
     expect(e.difference(o).to_set()).to(equal(set()))
Ejemplo n.º 28
0
 def test_str_if_self_is_empty(self):
     e = Set()
     expect(str(e)).to(equal('{}'))
Ejemplo n.º 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))
Ejemplo n.º 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}))