예제 #1
0
def test_multiply_many_numbers():
    c = Calc()

    s = range(1, 10)

    res = c.multiply(*s)

    assert res == 362880
예제 #2
0
def test_add_many_numners():
    c = Calc()

    s = range(100)

    res = c.add(*s)

    assert res == 4950
예제 #3
0
def test_outlier_removal_from_empty_list():
    assert Calc().avg([], upLimit=3) == 'inf'
예제 #4
0
def test_average_down_treshold():
    assert Calc().avg(range(0, 101), downLimit=50) == 75.5
예제 #5
0
def test_average_empty():
    assert Calc().avg([]) == 'inf'
예제 #6
0
def test_multiply_by_zero_raises_exception():
    with pytest.raises(ValueError):  # contects manager
        Calc().mult(4, 0)
예제 #7
0
def test_divide_two_numbers():
    assert Calc().div(22, 2) == 11
예제 #8
0
def test_subtract_two_numbers():
    assert Calc().sub(9, 4) == 5
예제 #9
0
def test_sub_two_numbers():
    c = Calc()
    res = c.sub(10, 3)
    assert res == 7
예제 #10
0
def testAverageRemovesLowerOutliersEquality():
    assert Calc().average([2, 5, 12, 98], lt=10) == pytest.approx(55)
예제 #11
0
def testAverageRemovesUpperOutliersEquality():
    assert Calc().average([2, 5, 12, 98], ut=12) == pytest.approx(6.33333)
예제 #12
0
def testAverageIterable():
    assert Calc().average([2, 5, 12, 98]) == 29.25
예제 #13
0
def testDivideByZeroReturnsInf():
    assert Calc().divide(11, 0) == "inf"
예제 #14
0
def testDivideReturnsFloats():
    assert Calc().divide(11, 2) == 5.5
예제 #15
0
def testDivideTwoNumbers():
    assert Calc().divide(22, 2) == 11
예제 #16
0
def test_add_three_numbers():
    c = Calc()
    result = c.add(5, 4, 1)

    assert result == 10
예제 #17
0
def test_add_multiple_items():
    c = Calc()
    result = c.add(*range(1, 100))

    assert result == 4950
예제 #18
0
def test_multiply_two_numbers():
    c = Calc()
    res = c.mul(6, 4)
    assert res == 24
예제 #19
0
def test_multiply_two_numbers():
    assert Calc().mult(3, 4) == 12
예제 #20
0
def test_add_two_numbers():
    c = Calc()
    res = c.add(4, 5)
    assert res == 9
예제 #21
0
def test_divide_by_zero():
    assert Calc().div(10, 0) == 'inf'
예제 #22
0
def test_multiply_many_numbers():
    s = range(1, 10)
    assert Calc().mul(*s) == 362880
예제 #23
0
def test_average():
    assert Calc().avg(range(0, 101)) == 50
예제 #24
0
def test_divide_returns_floats():
    assert Calc().div(11, 2) == 5.5
예제 #25
0
def test_average_upp_treshold():
    assert Calc().avg(range(0, 101), upLimit=51) == 25
예제 #26
0
def test_divide_by_zero_returns_inf():
    assert Calc().div(5, 0) == "inf"
예제 #27
0
def test_average_thresholds_equal_thresholds():
    assert Calc().avg([2, 3, 5, 6, 4, 36, 7, 1], downLimit=0,
                      upLimit=0) == 'inf'
예제 #28
0
def test_add_three_numbers():
    c = Calc()
    res = c.add(4, 5, 6)
    assert res == 15
예제 #29
0
def test_avg_manages_non_iterable_type():
    with pytest.raises(TypeError):
        Calc().avg(123)
예제 #30
0
def test_add():
    c = Calc()
    result = c.add(5, 4)

    assert result == 9  # this is not enough of a test bc we can just hardcode 9