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})}))
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)
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}))
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()))
def test_len_if_empty(self): e = Set() expect(len(e)).to(equal(0))
def test_isdisjoint_if_param_is_different(self): e = Set({1, 2, 3}) expect(e.isdisjoint('...')).to(be_false)
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}))
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}))
def test_and_other_is_different(self): e = Set({1, 2, 3}) expect(lambda: e & None).to(raise_error(TypeError))
def test_and_other_without_intersection(self): e = Set({1, 2, 3}) expect((e & {4, 5, 6}).to_set()).to(equal(set()))
def test_eq_other_not_equal(self): e = Set({1, 2, 3, 4}) o = {3, 4, 5, 6} expect(e == o).to(be_false)
def test_eq_other_is_different(self): e = Set({1, 2, 3}) expect(e == 1).to(be_false)
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)
def test_eq_other_is_equal(self): e = Set({1, 2, 3}) o = {3, 2, 1} expect(e == o).to(be_false)
def test_eq_other_greater_len(self): e = Set({1, 2, 3}) o = {1, 2, 3, 4} expect(e == o).to(be_false)
def test_add_if_set_is_empty(self): e = Set() expect(e.add(1).to_set()).to(equal({1}))
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}))
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}))
def test_reject_if_set_is_empty(self): e = Set({1, 2, 3}) expect(lambda: e.reject('...')).to(raise_error(TypeError))
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}))
def test_isdisjoint_if_disjoint(self): e = Set({1, 2, 3, 4}) expect(e.isdisjoint(Set({5, 6, 7}))).to(be_true)
def test_union_other_is_different(self): e = Set({1, 2, 3}) expect(lambda: e.union(None)).to(raise_error(TypeError))
def test_isdisjoint_if_have_intersection(self): e = Set({1, 2, 3, 4}) expect(e.isdisjoint({1, 2, 7})).to(be_false)
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})))
def test_len_if_not_empty(self): e = Set({1, 2, 3, 4}) expect(len(e)).to(equal(4))
def test_str_if_self_contains_elements(self): e = Set({1, 2, 3, 4}) expect(str(e)).to(equal('{1, 2, 3, 4}'))
def test_difference_if_set_is_empty(self): e = Set() o = {1, 2} expect(e.difference(o).to_set()).to(equal(set()))
def test_str_if_self_is_empty(self): e = Set() expect(str(e)).to(equal('{}'))
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))
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}))