def test_delitem(): value = [1, 2, 3] expected = list(value) a = param.List(value, hardbounds=[0, 4]) del a[0] del expected[0] assert a.value == expected
def test_creation_hardbounds_tuple(): """Test List - correct initilization""" value = [1] hardbounds = (0, 2) item = param.List(value=value, hardbounds=hardbounds) assert item.value == value assert item.hardbounds == list(hardbounds)
def test_creation_hardbounds(): """Test List - correct initilization""" value = [1] hardbounds = [0, 2] item = param.List(value=value, hardbounds=hardbounds) assert item.value == value assert item.hardbounds == hardbounds
def test_setitem(): """Test List""" value = [1, 2, 3] expected = list(value) a = param.List(value, hardbounds=[0, 4]) a[0] = 42 expected[0] = 42 assert a.value == expected
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_outside_bounds_lower_one_set(): """Test List - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [1] __ = param.List(value=value, hardbounds=[2, None])
def test_creation_hardbounds_too_long(): """Test List - correct initilization""" with pytest.raises(ValueError) as __: value = [1] hardbounds = [0, 2, 4] __ = param.List(value=value, hardbounds=hardbounds)
def test_kind(): """Test List - correct initilization""" value = [1, 2312314] item = param.List(value=value) assert item.kind == "List"
def test_notallow_none(): """Test item - incorrect initilization""" with pytest.raises(ValueError) as __: value = None item = param.List(value=value, allow_None=False)
def test_allow_None(): """Test List - correct initilization""" value = None item = param.List(value=value, allow_None=True) assert item.value is value
def test_doc(): """Test item - correct initilization""" value = [1, 2, 3] doc = "I am a list" item = param.List(value=value, doc=doc) assert item.doc == doc
def test_creation_good_int(): """Test List - correct initilization""" value = [1, 2, 3] item = param.List(value=value) assert item.value == value
def test_contains(): """Test List""" a = param.List([1, 2, 3], hardbounds=[0, 4]) assert 1 in a
def test_creation_str(): """Test List - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = "hello" __ = param.List(value=value)
def test_creation_outside_bounds_upper(): """Test List - throw error due to incorrect initilization""" with pytest.raises(ValueError) as __: value = [1, 3, 4, 5] __ = param.List(value=value, hardbounds=[0, 3])
def test_creation_good_str(): """Test List - correct initilization""" value = ["boo", "hoo"] item = param.List(value=value) assert item.value == value