Example #1
0
def test_head_nonempty_dict():
    """ Verify that head of nonempty dictionary is non-exceptional. """
    head({"a": 1, "b": 2})
Example #2
0
def test_head_nonempty_set():
    """ Verify that head of nonempty set is non-exceptional. """
    head({-1, 0, 1})
Example #3
0
def test_head_nonempty_sequential_collection(h, xs, seqtype, iter_cast):
    """ Verify accuracy of request for first element from nonempty Iterable. """
    c = seqtype([h]) + seqtype(xs)
    assert h == head(iter_cast(c))
Example #4
0
def test_head_empty_collection(coll):
    """ Request for first element from an empty Iterable is exceptional. """
    with pytest.raises(ValueError):
        head(coll)
Example #5
0
def test_head_empty_string():
    """ Empty string is exception to exceptional-ness of empty collection. """
    assert "" == head("")
Example #6
0
def test_head_atomic(obj):
    """ head() of an atomic object is the object itself. """
    assert obj == head(obj)