Пример #1
0
def test_get_param_invalid_value_gt(value):
    with pytest.raises(ValueError, match=f"Value {value} must be > 0.0"):
        pt.get_param(value, 'kelvin', gt=0.0)
Пример #2
0
def test_get_param_invalid_value_ge():
    with pytest.raises(ValueError, match="Value -100.0 must be >= 0.0"):
        pt.get_param(-1.0, 'm', ge=0.0)
Пример #3
0
def test_get_param_invalid_str_units():
    with pytest.raises(ValueError, match="Invalid units for value '1 unit'"):
        pt.get_param('1 unit')
Пример #4
0
def test_get_param_invalid_units():
    with pytest.raises(ValueError, match="Invalid units 'unit'"):
        pt.get_param('1.0', 'unit')
Пример #5
0
def test_get_param_invalid_str_many_values():
    with pytest.raises(ValueError, match="Invalid value '1 3 km'"):
        pt.get_param('1 3 km')
Пример #6
0
def test_get_param_invalid_str_value():
    with pytest.raises(ValueError, match="Invalid value 'val'"):
        pt.get_param('val')
Пример #7
0
def test_get_param_none():
    assert pt.get_param(None, 'km') is None
Пример #8
0
def test_get_param_array():
    value = np.array([10.0, 20.0])
    np.testing.assert_allclose(pt.get_param(value, 'm'),
                               np.array([1000.0, 2000.0]))
Пример #9
0
def test_get_param(value, result):
    assert pt.get_param(value, 'km') == result