本文整理汇总了Python中sample.VirtualMethods.callVirtualMethod0方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualMethods.callVirtualMethod0方法的具体用法?Python VirtualMethods.callVirtualMethod0怎么用?Python VirtualMethods.callVirtualMethod0使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sample.VirtualMethods
的用法示例。
在下文中一共展示了VirtualMethods.callVirtualMethod0方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testMonkeyPatchOnVirtualMethod
# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import callVirtualMethod0 [as 别名]
def testMonkeyPatchOnVirtualMethod(self):
'''Injects new 'virtualMethod0' on a VirtualMethods instance and makes C++ call it.'''
vm = VirtualMethods()
pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
result1 = vm.virtualMethod0(pt, val, cpx, b)
result2 = vm.callVirtualMethod0(pt, val, cpx, b)
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b))
def myVirtualMethod0(obj, pt, val, cpx, b):
self.duck_method_called = True
return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier
vm.virtualMethod0 = types.MethodType(myVirtualMethod0, vm, VirtualMethods)
result1 = vm.callVirtualMethod0(pt, val, cpx, b)
self.assert_(self.duck_method_called)
result2 = vm.virtualMethod0(pt, val, cpx, b)
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(vm, pt, val, cpx, b) * self.multiplier)
# This is done to decrease the refcount of the vm object
# allowing the object wrapper to be deleted before the
# BindingManager. This is useful when compiling Shiboken
# for debug, since the BindingManager destructor has an
# assert that checks if the wrapper mapper is empty.
vm.virtualMethod0 = None