示例#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