def test_discard_only_removes_one_element(a): t = TopoSet(a) sizes = [len(t)] for item in a: t.discard(item) sizes.append(len(t)) assert all(a == b + 1 for a, b in pairwise(sizes))
def test_discarding_all_elements_results_in_an_empty_set(a): t = TopoSet(a) for item in a: t.discard(item) assert len(t) == 0
def test_non_containment_negative(a, b): included = a - b t = TopoSet(included) assert all(not (item not in t) for item in included)
def test_default_constructed_toposet_is_empty(): t = TopoSet() assert len(t) == 0
def test_non_containment_positive(a, b): included = a - b excluded = b - a t = TopoSet(included) assert all(item not in t for item in excluded)
def test_containment_negative(a, b): included = a - b excluded = b - a t = TopoSet(included) assert all(not (item in t) for item in excluded)
def test_containment_positive(a, b): included = a - b t = TopoSet(included) assert all(item in t for item in included)
def test_toposet_with_items_added_from_a_set_is_equal_to_the_set(items): t = TopoSet() for item in items: t.add(item) assert t == items
def test_toposet_construction_eliminates_duplicates(item, size): t = TopoSet([item] * size) assert list(t) == [item]
def test_toposet_eliminates_duplicates(items): t = TopoSet(items) t.update(items) assert list(t) == items
def test_toposet_updated_from_iterable_without_duplicates_has_same_length( items): t = TopoSet() for item in items: t.add(item) assert list(t) == items
def test_toposet_updated_from_iterable_without_duplicates_has_same_length( items): t = TopoSet() t.update(items) assert list(t) == items
def test_default_constructed_toposet_contains_no_items(): t = TopoSet() assert list(t) == []
def test_removing_an_item_not_present_silently_succeeds(a): b = max(a) + 1 t = TopoSet(a) with raises(KeyError): t.remove(b)
def test_discarding_an_item_not_present_silently_succeeds(a): b = max(a) + 1 t = TopoSet(a) t.discard(b)