本文整理汇总了Python中sample.ObjectType类的典型用法代码示例。如果您正苦于以下问题:Python ObjectType类的具体用法?Python ObjectType怎么用?Python ObjectType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testReparentWithTheSameParent
def testReparentWithTheSameParent(self):
'''Set the same parent twice to check if the ref continue the same'''
obj = ObjectType()
parent = ObjectType()
self.assertEqual(sys.getrefcount(obj), 2)
obj.setParent(parent)
self.assertEqual(sys.getrefcount(obj), 3)
obj.setParent(parent)
self.assertEqual(sys.getrefcount(obj), 3)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:9,代码来源:ownership_reparenting_test.py
示例2: testDeleteChild
def testDeleteChild(self):
'''Delete child in python should not invalidate child'''
parent = ObjectType()
child = ObjectType(parent)
name = ''.join(random.sample(string.letters, 5))
child.setObjectName(name)
del child
new_child = parent.children()[0]
self.assertEqual(new_child.objectName(), name)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:10,代码来源:ownership_delete_child_in_python_test.py
示例3: testObjectTypeReferenceAndPointer
def testObjectTypeReferenceAndPointer(self):
'''In C++ we have "function(const ObjectType&, int)",
in Python we add "function(ValueType)".'''
obj = ObjectType()
obj.setObjectName('sbrubbles')
multiplier = 3.0
control = len(obj.objectName()) * multiplier
self.assertEqual(SampleNamespace.passReferenceToObjectType(obj, multiplier), control)
control = len(obj.objectName())
self.assertEqual(SampleNamespace.passReferenceToObjectType(obj), control)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:10,代码来源:addedfunction_test.py
示例4: testParentDestructor
def testParentDestructor(self):
'''Delete parent object should invalidate child'''
parent = ObjectType()
child = ObjectType()
child.setParent(parent)
refcount_before = sys.getrefcount(child)
del parent
self.assertRaises(RuntimeError, child.objectName)
self.assertEqual(sys.getrefcount(child), refcount_before-1)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:11,代码来源:ownership_delete_parent_test.py
示例5: testReparentedObjectTypeIdentityWithChildrenCreatedInCpp
def testReparentedObjectTypeIdentityWithChildrenCreatedInCpp(self):
'''Reparent children created in C++ from one parent to another.'''
object_list = []
old_parent = ObjectType()
new_parent = ObjectType()
for i in range(3):
obj = ObjectType.create()
object_list.append(obj)
obj.setParent(old_parent)
for obj in object_list:
obj.setParent(new_parent)
for child in new_parent.children():
self.assert_(child in object_list)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:13,代码来源:ownership_reparenting_test.py
示例6: testDeleteChild
def testDeleteChild(self):
'''Delete child in C++ should invalidate child - using C++ wrapper'''
parent = ObjectType()
parent.setObjectName('parent')
child = ObjectType(parent)
child.setObjectName('child')
parent.killChild('child')
self.assertRaises(RuntimeError, child.objectName)
self.assertEqual(parent.objectName(), 'parent')
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:10,代码来源:ownership_delete_child_in_cpp_test.py
示例7: testNextInFocusChainCycleList
def testNextInFocusChainCycleList(self):
'''As above but in for a list of objects'''
parents = []
children = []
focus_chains = []
for i in range(10):
parent = ObjectType()
child = ObjectType(parent)
next_focus = child.nextInFocusChain()
parents.append(parent)
children.append(child)
focus_chains.append(next_focus)
shiboken.invalidate(parents)
开发者ID:OpenGeoscience,项目名称:shiboken,代码行数:14,代码来源:objecttype_test.py
示例8: testCpp
def testCpp(self):
'''C++ calling C++ virtual method in multiple inheritance scenario'''
obj = ImplementsNone()
self.assert_(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT)))
self.assertRaises(AttributeError, getattr, obj, 'event_processed')
self.assertEqual(obj.callSum0(1, 2, 3), 6)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:7,代码来源:mi_virtual_methods_test.py
示例9: testEvent
def testEvent(self):
'''C++ calling Python reimplementation of virtual in multiple inheritance'''
obj = ImplementsBoth()
self.assert_(ObjectType.processEvent([obj], Event(Event.BASIC_EVENT)))
self.assert_(obj.event_processed)
self.assertEqual(obj.callSum1(1, 2, 3), 12)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:7,代码来源:mi_virtual_methods_test.py
示例10: testOwnershipTransferenceCppCreated
def testOwnershipTransferenceCppCreated(self):
'''Ownership transference using a C++ created object.'''
o1 = ObjectType.create()
o1.setObjectName('object1')
o1_refcnt = sys.getrefcount(o1)
bb = BlackBox()
o1_ticket = bb.keepObjectType(o1)
self.assertRaises(RuntimeError, o1.objectName)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:8,代码来源:ownership_transference_test.py
示例11: testEventLoop
def testEventLoop(self):
'''Calling virtuals in a event loop'''
objs = [ObjectType(), NoOverride(), Override()]
evaluated = ObjectType.processEvent(objs,
Event(Event.BASIC_EVENT))
self.assertEqual(evaluated, 3)
self.assert_(objs[2].called)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:9,代码来源:event_loop_call_virtual_test.py
示例12: testUseDefaultValues
def testUseDefaultValues(self):
o = ObjectType()
o.setObjectNameWithSize(size=3)
self.assertEqual(o.objectName(), "<un") # use name='unknown' default argument
o.setObjectSplittedName("")
self.assertEqual(o.objectName(), "<unknown>") # user prefix='<unk' and suffix='nown>'
开发者ID:Hasimir,项目名称:Shiboken,代码行数:8,代码来源:objecttype_with_named_args_test.py
示例13: testBasic
def testBasic(self):
'''Allowing threads and calling virtuals from C++'''
number = 10
objs = [Producer() for x in range(number)]
thread = Collector(objs)
thread.start()
evaluated = ObjectType.processEvent(objs,
Event(Event.BASIC_EVENT))
thread.join()
producer_data = [x.data for x in objs]
self.assertEqual(evaluated, number)
self.assertEqual(producer_data, thread.data)
开发者ID:BadSingleton,项目名称:shiboken2,代码行数:16,代码来源:event_loop_thread_test.py
示例14: testOwnershipTransference
def testOwnershipTransference(self):
'''Ownership transference from Python to C++ and back again.'''
o1 = ObjectType()
o1.setObjectName('object1')
o1_refcnt = sys.getrefcount(o1)
o2 = ObjectType()
o2.setObjectName('object2')
o2_refcnt = sys.getrefcount(o2)
bb = BlackBox()
o1_ticket = bb.keepObjectType(o1)
o2_ticket = bb.keepObjectType(o2)
self.assertEqual(set(bb.objects()), set([o1, o2]))
self.assertEqual(str(o1.objectName()), 'object1')
self.assertEqual(str(o2.objectName()), 'object2')
self.assertEqual(sys.getrefcount(o1), o1_refcnt + 1) # PySide give +1 ref to object with c++ ownership
self.assertEqual(sys.getrefcount(o2), o2_refcnt + 1)
o2 = bb.retrieveObjectType(o2_ticket)
self.assertEqual(sys.getrefcount(o2), o2_refcnt)
del bb
self.assertRaises(RuntimeError, o1.objectName)
self.assertEqual(str(o2.objectName()), 'object2')
self.assertEqual(sys.getrefcount(o2), o2_refcnt)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:22,代码来源:ownership_transference_test.py
示例15: testInvalidateChild
def testInvalidateChild(self):
'''Invalidating method call should remove child from the care of a parent if it has one.'''
parent = ObjectType()
child1 = ObjectType(parent)
child1.setObjectName('child1')
child2 = ObjectType.create()
child2.setParent(parent)
child2.setObjectName('child2')
self.assertEqual(parent.children(), [child1, child2])
bbox = BlackBox()
# This method steals ownership from Python to C++.
bbox.keepObjectType(child1)
self.assertEqual(parent.children(), [child2])
bbox.keepObjectType(child2)
self.assertEqual(parent.children(), [])
del parent
self.assertEqual(child1.objectName(), 'child1')
self.assertRaises(RuntimeError, child2.objectName)
开发者ID:Hasimir,项目名称:Shiboken,代码行数:24,代码来源:ownership_invalidate_child_test.py
示例16: testWithInt
def testWithInt(self):
'''Overload with Enums and ints with default value'''
o = ObjectType()
self.assertEqual(o.callWithEnum('', Event.ANY_EVENT, 9), 81)
self.assertEqual(o.callWithEnum('', 9), 9)
开发者ID:OdyX,项目名称:Shiboken,代码行数:6,代码来源:enum_test.py
示例17: testMoreArguments
def testMoreArguments(self):
o = ObjectType()
o.setObjectSplittedName("", prefix="pys", suffix="ide")
self.assertEqual(o.objectName(), "pyside")
o.setObjectSplittedName("", suffix="ide", prefix="pys")
self.assertEqual(o.objectName(), "pyside")
o.setObjectNameWithSize(name="pyside", size=6)
self.assertEqual(o.objectName(), "pyside")
o.setObjectNameWithSize(size=6, name="pyside")
self.assertEqual(o.objectName(), "pyside")
开发者ID:Hasimir,项目名称:Shiboken,代码行数:14,代码来源:objecttype_with_named_args_test.py
示例18: testObjectTypeSetObjectNameWithStrVariable
def testObjectTypeSetObjectNameWithStrVariable(self):
'''ObjectType.setObjectName with Str variable as argument.'''
s = Str('object name')
o = ObjectType()
o.setObjectName(s)
self.assertEqual(str(o.objectName()), str(s))
开发者ID:OpenGeoscience,项目名称:shiboken,代码行数:6,代码来源:objecttype_test.py
示例19: __init__
def __init__(self):
ObjectType.__init__(self)
VirtualMethods.__init__(self)
self.event_processed = False
开发者ID:Hasimir,项目名称:Shiboken,代码行数:4,代码来源:mi_virtual_methods_test.py
示例20: testObjectTypeSetObjectNameWithStrInstantiation
def testObjectTypeSetObjectNameWithStrInstantiation(self):
'''ObjectType.setObjectName with Str instantiation as argument.'''
s = 'object name'
o = ObjectType()
o.setObjectName(Str(s))
self.assertEqual(str(o.objectName()), s)
开发者ID:OpenGeoscience,项目名称:shiboken,代码行数:6,代码来源:objecttype_test.py
注:本文中的sample.ObjectType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论