def __init__(self): param.ParameterStore.__init__(self) self.param_int = param.Integer(value=666) self.param_num = param.Number(value=42.0) self.param_color = param.Color(value="#FFF000") self.param_choice = param.Choice(value="boo", choices=["boo", "baa"]) self.param_str = param.String("hello", doc="Old doc") self.param_regex = param.String(value="127.0.0.1", regex=ip_regex) self.param_bool = param.Boolean(False) self.param_option = param.Option(value=None, choices=[True, False]) self.param_range = param.Range(value=[-100, 100], hardbounds=[-200, None]) self.param_list = param.List(value=[1, 2, 3], hardbounds=[0, 10])
def test_creation_list(): with pytest.raises(ValueError) as __: value = list() __ = param.Boolean(value=value)
def test_notallow_none(): with pytest.raises(ValueError) as __: value = None __ = param.Boolean(value=value, allow_None=False)
def test_creation_int(): """Test Boolean - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = 42 __ = param.Boolean(value=value)
def test_creation_str(): with pytest.raises(ValueError) as __: value = "true" __ = param.Boolean(value=value)
def test_allow_none(): """Test Boolean - correct initilization""" value = None bool_a = param.Boolean(value=value, allow_None=True) assert bool_a.value == value
def test_kind(): """Test Boolean - correct initilization""" value = True bool_a = param.Boolean(value=value) assert bool_a.kind == "Boolean"
def test_creation_int_1(): """Test Boolean - correct initilization""" value = 1 bool_a = param.Boolean(value=value) assert bool_a.value == value
def test_creation_bool_false(): """Test Boolean - correct initilization""" value = True bool_a = param.Boolean(value=value) assert bool_a.value == value
def test_mul(): """Test Boolean - correct initilization""" with pytest.raises(ValueError) as __: value = True bool_a = param.Boolean(value=value) bool_a.value *= 0.5