Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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
Ejemplo n.º 4
0
 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])
Ejemplo n.º 6
0
 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])
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
    def test_kind():
        """Test List - correct initilization"""
        value = [1, 2312314]
        item = param.List(value=value)

        assert item.kind == "List"
Ejemplo n.º 9
0
 def test_notallow_none():
     """Test item - incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = None
         item = param.List(value=value, allow_None=False)
Ejemplo n.º 10
0
 def test_allow_None():
     """Test List - correct initilization"""
     value = None
     item = param.List(value=value, allow_None=True)
     assert item.value is value
Ejemplo n.º 11
0
 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
Ejemplo n.º 12
0
 def test_creation_good_int():
     """Test List - correct initilization"""
     value = [1, 2, 3]
     item = param.List(value=value)
     assert item.value == value
Ejemplo n.º 13
0
 def test_contains():
     """Test List"""
     a = param.List([1, 2, 3], hardbounds=[0, 4])
     assert 1 in a
Ejemplo n.º 14
0
 def test_creation_str():
     """Test List - throw error due to incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = "hello"
         __ = param.List(value=value)
Ejemplo n.º 15
0
 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])
Ejemplo n.º 16
0
 def test_creation_good_str():
     """Test List - correct initilization"""
     value = ["boo", "hoo"]
     item = param.List(value=value)
     assert item.value == value