Example #1
0
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))
Example #2
0
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
Example #3
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)
Example #4
0
def test_default_constructed_toposet_is_empty():
    t = TopoSet()
    assert len(t) == 0
Example #5
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)
Example #6
0
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)
Example #7
0
def test_containment_positive(a, b):
    included = a - b
    t = TopoSet(included)
    assert all(item in t for item in included)
Example #8
0
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
Example #9
0
def test_toposet_construction_eliminates_duplicates(item, size):
    t = TopoSet([item] * size)
    assert list(t) == [item]
Example #10
0
def test_toposet_eliminates_duplicates(items):
    t = TopoSet(items)
    t.update(items)
    assert list(t) == items
Example #11
0
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
Example #12
0
def test_toposet_updated_from_iterable_without_duplicates_has_same_length(
        items):
    t = TopoSet()
    t.update(items)
    assert list(t) == items
Example #13
0
def test_default_constructed_toposet_contains_no_items():
    t = TopoSet()
    assert list(t) == []
Example #14
0
def test_removing_an_item_not_present_silently_succeeds(a):
    b = max(a) + 1
    t = TopoSet(a)
    with raises(KeyError):
        t.remove(b)
Example #15
0
def test_discarding_an_item_not_present_silently_succeeds(a):
    b = max(a) + 1
    t = TopoSet(a)
    t.discard(b)