示例#1
0
    def test_allow_none():
        """Test Choice - correct initilization"""
        value = None
        choices = [True, False]
        choice = param.Choice(value=value, choices=choices, allow_None=True)

        assert choice.kind == "Choice"
示例#2
0
 def test_creation_bool():
     """Test Choice - correct initilization"""
     value = False
     choices = [True, False]
     choice = param.Choice(value=value, choices=choices)
     assert choice.value == value
     assert choice.choices == choices
示例#3
0
 def test_doc():
     """Test Choice - correct initilization"""
     value = "boo"
     choices = ["boo", "foo"]
     doc = "I am a choice"
     choice = param.Choice(value=value, doc=doc, choices=choices)
     assert choice.doc == doc
示例#4
0
 def test_creation_good():
     """Test Choice - correct initilization"""
     value = "boo"
     choices = ["boo", "foo"]
     choice = param.Choice(value=value, choices=choices)
     assert choice.value == value
     assert choice.choices == choices
示例#5
0
 def test_contains_str():
     """Test Choice - correct initilization"""
     value = "abc"
     choices = ["abc", "cde"]
     choice = param.Choice(value=value, choices=choices)
     assert choice.value == value
     assert choice.choices == choices
     assert "a" in choice
示例#6
0
    def test_change_choices():
        """Test Choice - correct initilization"""
        value = "boo"
        choices = ["boo", "foo"]
        choice = param.Choice(value=value, choices=choices)
        assert choice.value == value
        assert choice.choices == choices

        choices = ["boo", "foo", "baz"]
        choice.choices = choices
        assert choice.choices == choices
 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])
示例#8
0
 def test_notallow_none():
     """Test Choice - incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = None
         choices = [True, False]
         __ = param.Choice(value=value, choices=choices, allow_None=False)
示例#9
0
 def test_missing_choice_not_list():
     """Test Choice - incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = "true"
         choices = "true"
         __ = param.Choice(value=value, choices=choices)
示例#10
0
 def test_missing_in_choice():
     """Test Choice - incorrect initilization"""
     with pytest.raises(ValueError) as __:
         value = "true"
         choices = [True, False]
         __ = param.Choice(value=value, choices=choices)