Skip to content

Test Functions

Test for have_digits

Source code in test_functions.py
19
20
21
@pytest.mark.parametrize('s, expected_cool', [('adasdda', 0), ('asd12', 1), ('sdasdasdadasdas', 0)])
def test_have_digits(s, expected_cool):
    assert have_digits(s) == expected_cool

Test for my_thermo_stat

Source code in test_functions.py
14
15
16
17
@pytest.mark.parametrize("temp, desired_temp, expectation", [(15,5, 'AC'), (10.0,12.0, 'off'), (-5.0,5.5,'Heat')])
def test_my_thermo_stat(temp, desired_temp, expectation):
    assert my_thermo_stat(-10, 15) == 'Heat'
    assert my_thermo_stat(temp, desired_temp) == expectation

Test for my_adder

Source code in test_functions.py
 8
 9
10
11
@pytest.mark.parametrize("a, b, c, expected", [(1,1,1, 3), (10,20,30,60), (-1.0,-2.0,3,0)])
def test_my_adder(a,b,c, expected):
    assert my_adder(1, 2, 3) == 6
    assert my_adder(a,b,c) == expected