本文整理汇总了Python中SettingsTree.Leaf.allowed_values方法的典型用法代码示例。如果您正苦于以下问题:Python Leaf.allowed_values方法的具体用法?Python Leaf.allowed_values怎么用?Python Leaf.allowed_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SettingsTree.Leaf
的用法示例。
在下文中一共展示了Leaf.allowed_values方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_validation_mixed_invalid_alwaysfalse_butallowed
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_validation_mixed_invalid_alwaysfalse_butallowed():
leaf = Leaf()
x = random.random()
leaf.validator_function = lambda x, y: False
leaf.allowed_values = [x]
leaf.value = x
assert not leaf.is_valid(settings)
示例2: test_validation_mixed_invalid_allowedvalue_butwrongtype
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_validation_mixed_invalid_allowedvalue_butwrongtype():
leaf = Leaf()
x = random.randrange(100)
leaf.valid_value_types = float
leaf.allowed_values = [x]
leaf.value = x
assert not leaf.is_valid(settings)
示例3: test_validation_allowed_values_invalid
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_validation_allowed_values_invalid():
leaf = Leaf()
x = [random.random() for i in range(5, 10)]
leaf.allowed_values = x
y = x[0]
while y in x:
y = random.random()
leaf.value = y
assert not leaf.is_valid(settings)
示例4: test_set_allowed_values
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_set_allowed_values():
leaf = Leaf()
x = [random.random() for i in range(random.randint(4, 30))]
leaf.allowed_values = x
out = leaf.allowed_values
assert isinstance(out, collections.Iterable)
assert len(x) == len(out)
for i, v in enumerate(x):
assert v == out[i]
示例5: test_validation_allowed_values_valid
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_validation_allowed_values_valid():
leaf = Leaf()
x = [random.random() for i in range(5, 10)]
leaf.allowed_values = x
leaf.value = x[random.randrange(len(x))]
assert leaf.is_valid(settings)
示例6: test_set_allowed_values_invalid_noniterable
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_set_allowed_values_invalid_noniterable():
leaf = Leaf()
x = 9
leaf.allowed_values = x
示例7: test_undo_allowed_values
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import allowed_values [as 别名]
def test_undo_allowed_values():
leaf = Leaf(allowed_values=(3,))
assert leaf.allowed_values is not None
x = None
leaf.allowed_values = x
assert x == leaf.allowed_values