本文整理匯總了Python中traitlets.Int方法的典型用法代碼示例。如果您正苦於以下問題:Python traitlets.Int方法的具體用法?Python traitlets.Int怎麽用?Python traitlets.Int使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類traitlets
的用法示例。
在下文中一共展示了traitlets.Int方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_special_types
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_special_types():
obj, sig = dbus_prepare(Color.NewFromHtml('black'))
assert obj == '#000000'
assert sig == 's'
obj, sig = dbus_prepare(Int(5))
assert isinstance(obj, dict)
assert sig == 'a{sv}'
for value in obj.values():
assert isinstance(value, GLib.Variant)
obj, sig = dbus_prepare(EnumTest)
assert isinstance(obj, tuple)
assert sig == '(sss)'
示例2: test_typed_tuple_uninitialized_ints
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_typed_tuple_uninitialized_ints():
class TestCase(HasTraits):
value = TypedTuple(trait=Int())
obj = TestCase()
assert obj.value == ()
示例3: test_typed_tuple_init_ints
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_typed_tuple_init_ints():
class TestCase(HasTraits):
value = TypedTuple(trait=Int())
obj = TestCase(value=(1, 2, 3))
assert obj.value == (1, 2, 3)
示例4: test_typed_tuple_set_ints
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_typed_tuple_set_ints():
class TestCase(HasTraits):
value = TypedTuple(trait=Int())
obj = TestCase()
obj.value = (1, 2, 3)
assert obj.value == (1, 2, 3)
示例5: test_typed_tuple_bad_default
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_typed_tuple_bad_default():
class TestCase(HasTraits):
value = TypedTuple(trait=Int(), default_value=(1, 2, 'foobar'))
with nt.assert_raises(TraitError):
obj = TestCase()
a = obj.value # a read might be needed to trigger default validation
示例6: test_typed_tuple_bad_set
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_typed_tuple_bad_set():
class TestCase(HasTraits):
value = TypedTuple(trait=Int())
obj = TestCase()
with nt.assert_raises(TraitError):
obj.value = (1, 2, 'foobar')
示例7: test_set_state_int_to_float
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_set_state_int_to_float():
w = NumberWidget()
# Set Int to float
with nt.assert_raises(TraitError):
w.set_state(dict(
i = 3.5
))
示例8: test_has_traits
# 需要導入模塊: import traitlets [as 別名]
# 或者: from traitlets import Int [as 別名]
def test_has_traits():
""" test the has_traits func """
class WithoutTraits(HasTraits):
""" a traits class that has no traits """
pass
class WithATrait(HasTraits):
""" a traits class that has a trait """
my_trait = Int()
assert not has_traits(WithoutTraits)
assert has_traits(WithATrait)