Ejemplo n.º 1
0
def test_raises_exception():
    with pytest.raises(TypeError):
        sum_custom(1.0)
    with pytest.raises(TypeError):
        sum_custom("This is a string")
Ejemplo n.º 2
0
def test_negative():
    assert sum_custom(-1) == -1
    assert sum_custom(-10) == -1
Ejemplo n.º 3
0
def test_border_case():
    assert sum_custom(1) == 1
    assert sum_custom(0) == 0
    assert sum_custom(-1) == -1
    assert sum_custom(-2) == -1
Ejemplo n.º 4
0
def test_positive():
    # partitioning n
    assert sum_custom(2) == 0 + 1 + 2
    assert sum_custom(3) == 0 + 1 + 2 + 3
    assert sum_custom(5) == 15
    assert sum_custom(10) == 55