Пример #1
0
def test_oddity():
    """Test oddities of all_equal."""
    # all_equal doesn't consume the iterator after the first non-equal
    data = iter("ABCD")
    res = all_equal(data)
    assert res is False
    assert list(data) == ["C", "D"]
Пример #2
0
def test_normal_equal():
    """Test all_equal."""
    # all_equal with success
    data = iter("AAAAA")
    res = all_equal(data)
    assert res is True
    assert list(data) == []

    # all_equal with no success
    data = iter("AAAAB")
    res = all_equal(data)
    assert res is False
    assert list(data) == []

    # all_equal with empty
    data = ()
    res = all_equal(data)
    assert res is True