本文整理匯總了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]