本文整理匯總了Python中SettingsTree.Leaf.value方法的典型用法代碼示例。如果您正苦於以下問題:Python Leaf.value方法的具體用法?Python Leaf.value怎麽用?Python Leaf.value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SettingsTree.Leaf
的用法示例。
在下文中一共展示了Leaf.value方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_validation_validators_LessThanOrEqualTo_valid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_LessThanOrEqualTo_valid():
leaf = Leaf()
validators = [['LessThanOrEqualTo', random.random()]]
leaf.validators = validators
leaf.value = validators[0][1]
assert leaf.is_valid(settings)
for i in range(100):
leaf.value = validators[0][1] - 100.0 * random.random()
assert leaf.is_valid(settings)
示例2: test_validation_validators_GreaterThan_invalid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_GreaterThan_invalid():
leaf = Leaf()
validators = [['GreaterThan', random.random()]]
leaf.validators = validators
leaf.value = validators[0][1]
assert not leaf.is_valid(settings)
for i in range(100):
leaf.value = validators[0][1] - 100.0 * random.random()
assert not leaf.is_valid(settings)
示例3: test_validation_mixed_invalid_allowedvalue_butwrongtype
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [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)
示例4: test_validation_validator_function_invalid_alwaysfalse
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validator_function_invalid_alwaysfalse():
leaf = Leaf()
leaf.validator_function = lambda x, y: False
x = [random.random() for i in range(10)] + [list, 'av', [3]]
for v in x:
leaf.value = v
assert not leaf.is_valid(settings)
示例5: test_validation_mixed_invalid_alwaysfalse_butallowed
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [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)
示例6: test_validation_mixed_invalid_alwaystrue_butforbidden
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_mixed_invalid_alwaystrue_butforbidden():
leaf = Leaf()
x = random.random()
leaf.validator_function = lambda x, y: True
leaf.forbidden_values = [x]
leaf.value = x
assert not leaf.is_valid(settings)
示例7: test_validation_validators_NotEqual_valid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_NotEqual_valid():
leaf = Leaf()
validators = [['NotEqual', random.random()]]
leaf.validators = validators
x = set([random.random() for i in range(100)])
for v in x:
leaf.value = v
assert leaf.is_valid(settings)
示例8: test_validation_validators_BetweenNotInclusive_invalid_bounds
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_BetweenNotInclusive_invalid_bounds():
leaf = Leaf()
bounds = sorted([random.random(), random.random()])
validators = [['Between', bounds], ['NotEqual', bounds[0]],
['NotEqual', bounds[1]]]
leaf.validators = validators
for v in bounds:
leaf.value = v
assert not leaf.is_valid(settings)
示例9: test_validation_validator_function_invalid_notequalsetting
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validator_function_invalid_notequalsetting():
leaf = Leaf()
name = random.choice(tuple(settings.keys()))
leaf.validator_function = lambda x, y: x == y[name]
x = set([random.random() for i in range(100)]) \
- set([settings[name]])
for v in x:
leaf.value = x
assert not leaf.is_valid(settings)
示例10: test_validation_validators_NotBetween_invalid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_NotBetween_invalid():
leaf = Leaf()
bounds = sorted([random.random(), random.random()])
validators = [['NotBetween', bounds]]
leaf.validators = validators
x = set([random.uniform(*bounds) for i in range(100)]) - set(bounds)
for v in x:
leaf.value = v
assert not leaf.is_valid(settings)
示例11: test_validation_allowed_values_invalid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [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)
示例12: test_validation_forbidden_values_valid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_forbidden_values_valid():
leaf = Leaf()
x = [random.random() for i in range(5, 10)]
leaf.forbidden_values = x
y = x[0]
while y in x:
y = random.random()
leaf.value = y
assert leaf.is_valid(settings)
示例13: test_validation_validators_Between_invalid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_Between_invalid():
leaf = Leaf()
bounds = sorted([random.random(), random.random()])
validators = [['Between', bounds]]
leaf.validators = validators
x = [min(bounds) - 100.0 * random.random() for i in range(100)] \
+ [max(bounds) + 100.0 * random.random() for i in range(100)]
for v in x:
leaf.value = v
assert not leaf.is_valid(settings)
示例14: test_validation_validator_function_invalid_exception
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validator_function_invalid_exception():
leaf = Leaf()
def fun(x, y):
raise TypeError('blah')
leaf.validator_function = fun
x = [random.random() for i in range(10)] + [list, 'av', [3]]
for v in x:
leaf.value = v
assert not leaf.is_valid(settings)
示例15: test_validation_validators_NotEqual_invalid
# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import value [as 別名]
def test_validation_validators_NotEqual_invalid():
leaf = Leaf()
validators = [['NotEqual', random.random()]]
leaf.validators = validators
leaf.value = validators[0][1]
assert not leaf.is_valid(settings)