Ejemplo n.º 1
0
def test_simple():
    num_list = [1, 2]
    observed = mean(num_list)
    expected = 1.5
    assert observed == expected
Ejemplo n.º 2
0
def test_type_error():
    with pytest.raises(TypeError):
        mean(5)
Ejemplo n.º 3
0
def test_many(num_list, expected_mean):
    assert mean(num_list) == expected_mean
Ejemplo n.º 4
0
def test_more(
    num_list
):  # pytest will scan for all the fixtures and search for num_lists
    assert mean(num_list) == 3.0
Ejemplo n.º 5
0
def test_empty():
    with pytest.raises(ZeroDivisionError):
        mean([])
Ejemplo n.º 6
0
def test_more(num_list):
    assert mean (num_list) == 3.0
Ejemplo n.º 7
0
def test_simple():
    num_list = [1, 2]
    observed = mean(num_list)
    expected = 1.5
    assert observed == expected  # assert : test boolean expression. If true, do nothing
Ejemplo n.º 8
0
def test_many(
    num_list, expected_mean
):  #We should do assert a==b every time..  So We can parametrize it.
    assert mean(num_list) == expected_mean
Ejemplo n.º 9
0
def test_type_error(num_list):
    with pytest.raises(TypeError):
        mean(num_list)
Ejemplo n.º 10
0
def test_empty():
    with pytest.raises(ZeroDivisionError
                       ):  #len(list)==0 ZeroDivisionError, if not, give error
        mean([])