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


Python Leaf.validator_function方法代码示例

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


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

示例1: test_validation_mixed_invalid_alwaystrue_butforbidden

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例2: test_validation_validator_function_invalid_alwaysfalse

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例3: test_validation_mixed_invalid_alwaysfalse_butallowed

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:9,代码来源:test_leaf.py

示例4: test_validation_validator_function_invalid_notequalsetting

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:11,代码来源:test_leaf.py

示例5: test_validation_validator_function_invalid_exception

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [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)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:13,代码来源:test_leaf.py

示例6: test_validation_validator_function_valid_equalsetting

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [as 别名]
def test_validation_validator_function_valid_equalsetting():
    leaf = Leaf()
    name = random.choice(tuple(settings.keys()))
    leaf.validator_function = lambda x, y: x == y[name]
    leaf.value = settings[name]
    assert leaf.is_valid(settings)
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:8,代码来源:test_leaf.py

示例7: test_set_validator_function_invalid_wrongnumberargs

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [as 别名]
def test_set_validator_function_invalid_wrongnumberargs():
    leaf = Leaf()
    x = lambda y, z, w: True
    leaf.validator_function = x
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:6,代码来源:test_leaf.py

示例8: test_set_validator_function_invalid_notfunction

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [as 别名]
def test_set_validator_function_invalid_notfunction():
    leaf = Leaf()
    x = 9.2
    leaf.validator_function = x
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:6,代码来源:test_leaf.py

示例9: test_undo_validator_function

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [as 别名]
def test_undo_validator_function():
    leaf = Leaf(validator_function=lambda y, z: True)
    assert leaf.validator_function is not None
    x = None
    leaf.validator_function = x
    assert x == leaf.validator_function
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:8,代码来源:test_leaf.py

示例10: test_set_validator_function

# 需要导入模块: from SettingsTree import Leaf [as 别名]
# 或者: from SettingsTree.Leaf import validator_function [as 别名]
def test_set_validator_function():
    leaf = Leaf()
    x = lambda y, z: True
    leaf.validator_function = x
    out = leaf.validator_function
    assert x == out
开发者ID:frejanordsiek,项目名称:SettingsTree,代码行数:8,代码来源:test_leaf.py


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