本文整理汇总了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)