本文整理汇总了Python中SettingsTree.Leaf.available_validators方法的典型用法代码示例。如果您正苦于以下问题:Python Leaf.available_validators方法的具体用法?Python Leaf.available_validators怎么用?Python Leaf.available_validators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SettingsTree.Leaf
的用法示例。
在下文中一共展示了Leaf.available_validators方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_set_validators
# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import available_validators [as 别名]
def test_set_validators():
leaf = Leaf()
avail_vals, nparams = leaf.available_validators()
x = []
for i, n in enumerate(nparams):
if n == 1:
x.append((avail_vals[i], random.random()))
else:
x.append((avail_vals[i],
[random.random(), random.random()]))
leaf.validators = x
out = leaf.validators
assert isinstance(out, collections.Iterable)
assert len(x) == len(out)
for i, v in enumerate(x):
assert isinstance(out[i], collections.Iterable)
assert len(v) == len(out[i])
assert v[0] == out[i][0]
if not isinstance(v[1], collections.Iterable):
assert v[1] == out[i][1]
else:
assert len(v[1]) == len(out[i][1])
for i2, v2 in enumerate(v[1]):
assert v2 == out[i][1][i2]