def test_head_nonempty_dict(): """ Verify that head of nonempty dictionary is non-exceptional. """ head({"a": 1, "b": 2})
def test_head_nonempty_set(): """ Verify that head of nonempty set is non-exceptional. """ head({-1, 0, 1})
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))
def test_head_empty_collection(coll): """ Request for first element from an empty Iterable is exceptional. """ with pytest.raises(ValueError): head(coll)
def test_head_empty_string(): """ Empty string is exception to exceptional-ness of empty collection. """ assert "" == head("")
def test_head_atomic(obj): """ head() of an atomic object is the object itself. """ assert obj == head(obj)