Exemple #1
0
def test_simple():
    num_list = [1, 2]
    observed = mean(num_list)
    expected = 1.5
    assert observed == expected
Exemple #2
0
def test_type_error():
    with pytest.raises(TypeError):
        mean(5)
Exemple #3
0
def test_many(num_list, expected_mean):
    assert mean(num_list) == expected_mean
Exemple #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
Exemple #5
0
def test_empty():
    with pytest.raises(ZeroDivisionError):
        mean([])
Exemple #6
0
def test_more(num_list):
    assert mean (num_list) == 3.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
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
def test_type_error(num_list):
    with pytest.raises(TypeError):
        mean(num_list)
def test_empty():
    with pytest.raises(ZeroDivisionError
                       ):  #len(list)==0 ZeroDivisionError, if not, give error
        mean([])