def test_simple(): num_list = [1, 2] observed = mean(num_list) expected = 1.5 assert observed == expected
def test_type_error(): with pytest.raises(TypeError): mean(5)
def test_many(num_list, expected_mean): assert mean(num_list) == expected_mean
def test_more( num_list ): # pytest will scan for all the fixtures and search for num_lists assert mean(num_list) == 3.0
def test_empty(): with pytest.raises(ZeroDivisionError): mean([])
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([])