Пример #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))
Пример #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
Пример #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)
Пример #4
0
def test_default_constructed_toposet_is_empty():
    t = TopoSet()
    assert len(t) == 0
Пример #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)
Пример #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)
Пример #7
0
def test_containment_positive(a, b):
    included = a - b
    t = TopoSet(included)
    assert all(item in t for item in included)
Пример #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
Пример #9
0
def test_toposet_construction_eliminates_duplicates(item, size):
    t = TopoSet([item] * size)
    assert list(t) == [item]
Пример #10
0
def test_toposet_eliminates_duplicates(items):
    t = TopoSet(items)
    t.update(items)
    assert list(t) == items
Пример #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
Пример #12
0
def test_toposet_updated_from_iterable_without_duplicates_has_same_length(
        items):
    t = TopoSet()
    t.update(items)
    assert list(t) == items
Пример #13
0
def test_default_constructed_toposet_contains_no_items():
    t = TopoSet()
    assert list(t) == []
Пример #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)
Пример #15
0
def test_discarding_an_item_not_present_silently_succeeds(a):
    b = max(a) + 1
    t = TopoSet(a)
    t.discard(b)