当前位置: 首页>>代码示例>>Python>>正文


Python SettingsTree.Leaf类代码示例

本文整理汇总了Python中SettingsTree.Leaf的典型用法代码示例。如果您正苦于以下问题:Python Leaf类的具体用法?Python Leaf怎么用?Python Leaf使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Leaf类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_validation_validator_function_invalid_alwaysfalse

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例2: test_validation_validators_LessThanOrEqualTo_invalid

def test_validation_validators_LessThanOrEqualTo_invalid():
    leaf = Leaf()
    validators = [['LessThanOrEqualTo', random.random()]]
    leaf.validators = validators
    for i in range(100):
        leaf.value = validators[0][1] + 100.0 * random.random()
        assert not leaf.is_valid(settings)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例3: test_validation_mixed_invalid_alwaysfalse_butallowed

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例4: test_validation_mixed_invalid_alwaystrue_butforbidden

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例5: test_validation_mixed_invalid_allowedvalue_butwrongtype

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例6: test_validation_validators_GreaterThan_valid

def test_validation_validators_GreaterThan_valid():
    leaf = Leaf()
    validators = [['GreaterThan', random.random()]]
    leaf.validators = validators
    for i in range(100):
        leaf.value = validators[0][1] + 100.0 * random.random()
        assert leaf.is_valid(settings)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:7,代码来源:test_leaf.py

示例7: test_validation_validators_NotEqual_valid

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:8,代码来源:test_leaf.py

示例8: test_set_valid_value_types_one_type

def test_set_valid_value_types_one_type():
    leaf = Leaf()
    x = int
    leaf.valid_value_types = x
    out = leaf.valid_value_types
    assert isinstance(out, collections.Iterable)
    assert len(out) == 1
    assert x == out[0]
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:8,代码来源:test_leaf.py

示例9: test_validation_forbidden_values_valid

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例10: test_validation_allowed_values_invalid

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例11: test_validation_validators_NotBetween_invalid

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例12: test_set_valid_value_types_many_types

def test_set_valid_value_types_many_types():
    leaf = Leaf()
    x = (int, float, type(None))
    leaf.valid_value_types = x
    out = leaf.valid_value_types
    assert isinstance(out, collections.Iterable)
    assert len(x) == len(out)
    for i, v in enumerate(x):
        assert v == out[i]
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例13: test_set_forbidden_values

def test_set_forbidden_values():
    leaf = Leaf()
    x = [random.random() for i in range(random.randint(4, 30))]
    leaf.forbidden_values = x
    out = leaf.forbidden_values
    assert isinstance(out, collections.Iterable)
    assert len(x) == len(out)
    for i, v in enumerate(x):
        assert v == out[i]
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例14: test_validation_validators_BetweenNotInclusive_invalid_bounds

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例15: test_validation_validator_function_invalid_notequalsetting

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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py


注:本文中的SettingsTree.Leaf类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。