Exemplo n.º 1
0
def test_temp_converter():
    assert math.isclose(session4.temp_converter(100, temp_given_in='f'),
                        37.7777777777,
                        abs_tol=0.01)
    assert math.isclose(session4.temp_converter(37.7777777777,
                                                temp_given_in='c'),
                        100,
                        abs_tol=0.01)
Exemplo n.º 2
0
def test_temp_converter_function_less_than_min():
    temp_base = ('f', 'k', 'c')
    temp_base = random.choice(temp_base)
    min_temperature = {'f': -459.67, 'k': 0, 'c': -273.15}
    temp = min_temperature.get(temp_base) - 1
    (temp1, temp1_b, temp2, temp2_b) = temp_converter(temp,
                                                      temp_given_in=temp_base)
    assert temp1 == None and temp2 == None, " Check temperature function for less than min values"
Exemplo n.º 3
0
def test_temp_converter_function_Celius_others():
    temp_c = random.uniform(-273.15, 1000)
    (temp1, temp1_b, temp2, temp2_b) = temp_converter(temp_c,
                                                      temp_given_in='c')
    temp1_c = temp_c * 9 / 5 + 32
    temp2_c = temp_c + 273.15
    assert math.isclose(temp1, temp1_c) and math.isclose(
        temp2, temp2_c), " Check temperature function for Celius convertion"
Exemplo n.º 4
0
def test_temp_converter_function_Kelvin_others():
    temp_k = random.uniform(0, 1000)
    (temp1, temp1_b, temp2, temp2_b) = temp_converter(temp_k,
                                                      temp_given_in='k')
    temp1_c = temp_k - 273.15
    temp2_c = (temp_k - 273.15) * 9 / 5 + 32
    assert math.isclose(temp1, temp1_c) and math.isclose(
        temp2, temp2_c), " Check temperature function for Kelvin convertion"
Exemplo n.º 5
0
def test_temp_converter_function_fahrenheit_others():
    temp_f = random.uniform(-459.67, 1000)
    (temp1, temp1_b, temp2, temp2_b) = temp_converter(temp_f,
                                                      temp_given_in='f')
    temp1_c = (temp_f - 32) / 1.8
    temp2_c = (temp_f - 32) / 1.8 + 273.15
    assert math.isclose(temp1, temp1_c) and math.isclose(
        temp2,
        temp2_c), " Check temperature function for fahrenheit convertion"
Exemplo n.º 6
0
def test_temp_converter_function_non_standard_base():
    temp_base = ('J')
    (temp1, temp1_b, temp2, temp2_b) = temp_converter(100,
                                                      temp_given_in=temp_base)
    assert temp1 == None and temp2 == None, " Check temperature function for less than min values"
Exemplo n.º 7
0
def test_temp_converter_invalid_value():
    with pytest.raises(ValueError):
        session4.temp_converter(123, temp_given_in='k')
Exemplo n.º 8
0
def test_temp_converter_invalid_args():
    with pytest.raises(TypeError):
        session4.temp_converter('123', temp_given_in='c')
        session4.temp_converter(98, temp_given_in=['f'])
Exemplo n.º 9
0
def test_temp_converter_typeerror():
    with pytest.raises(TypeError):
        program.temp_converter("a", temp_given_in="f")
Exemplo n.º 10
0
def test_temp_converter_valueerror():
    with pytest.raises(ValueError):
        program.temp_converter(32, temp_given_in="g")
Exemplo n.º 11
0
def test_temp_converter_f_to_c():
    assert math.isclose(program.temp_converter(32, temp_given_in="f"), 0)
Exemplo n.º 12
0
def test_temp_converter_c_to_f():
    assert math.isclose(program.temp_converter(0, temp_given_in="c"), 32.0)