當前位置: 首頁>>代碼示例>>Python>>正文


Python Leaf.validators方法代碼示例

本文整理匯總了Python中SettingsTree.Leaf.validators方法的典型用法代碼示例。如果您正苦於以下問題:Python Leaf.validators方法的具體用法?Python Leaf.validators怎麽用?Python Leaf.validators使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SettingsTree.Leaf的用法示例。


在下文中一共展示了Leaf.validators方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_validation_validators_LessThanOrEqualTo_invalid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
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,代碼行數:9,代碼來源:test_leaf.py

示例2: test_validation_validators_GreaterThan_valid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
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,代碼行數:9,代碼來源:test_leaf.py

示例3: test_validation_validators_NotEqual_valid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [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)
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:10,代碼來源:test_leaf.py

示例4: test_validation_validators_BetweenNotInclusive_invalid_bounds

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [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)
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:11,代碼來源:test_leaf.py

示例5: test_validation_validators_NotBetween_invalid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [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)
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:11,代碼來源:test_leaf.py

示例6: test_validation_validators_Between_invalid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [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)
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:12,代碼來源:test_leaf.py

示例7: test_set_validators

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import 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]
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:26,代碼來源:test_leaf.py

示例8: test_validation_validators_NotEqual_invalid

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [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)
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:8,代碼來源:test_leaf.py

示例9: test_set_validators_invalid_nonnumber_parameter

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_nonnumber_parameter():
    leaf = Leaf()
    x = [['LessThan', 'a']]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例10: test_set_validators_invalid_two_insteadof_one_parameter

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_two_insteadof_one_parameter():
    leaf = Leaf()
    x = [['LessThan', [3, 2]]]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例11: test_set_validators_invalid_one_insteadof_two_parameters

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_one_insteadof_two_parameters():
    leaf = Leaf()
    x = [['Between', 3]]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例12: test_set_validators_invalid_nonavailable_validator

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_nonavailable_validator():
    leaf = Leaf()
    x = [['aivaanenfoaoefnaofve', 3]]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例13: test_set_validators_invalid_non2element_iterables

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_non2element_iterables():
    leaf = Leaf()
    x = [['LessThan']]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例14: test_set_validators_invalid_not_iterable_of_iterables

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_not_iterable_of_iterables():
    leaf = Leaf()
    x = [1]
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py

示例15: test_set_validators_invalid_noniterable

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import validators [as 別名]
def test_set_validators_invalid_noniterable():
    leaf = Leaf()
    x = 9
    leaf.validators = x
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:6,代碼來源:test_leaf.py


注:本文中的SettingsTree.Leaf.validators方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。