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


Python Leaf.valid_value_types方法代碼示例

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


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

示例1: test_validation_mixed_invalid_allowedvalue_butwrongtype

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

示例2: test_set_valid_value_types_one_type

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

示例3: test_set_valid_value_types_many_types

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

示例4: test_undo_valid_value_types

# 需要導入模塊: from SettingsTree import Leaf [as 別名]
# 或者: from SettingsTree.Leaf import valid_value_types [as 別名]
def test_undo_valid_value_types():
    leaf = Leaf(valid_value_types=int)
    assert leaf.valid_value_types is not None
    x = None
    leaf.valid_value_types = x
    assert x == leaf.valid_value_types
開發者ID:frejanordsiek,項目名稱:SettingsTree,代碼行數:8,代碼來源:test_leaf.py

示例5: test_set_valid_value_types_list_with_one_invalid

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

示例6: test_set_valid_value_types_one_invalid

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


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