本文整理汇总了Python中sample.VirtualMethods.virtualMethod0方法的典型用法代码示例。如果您正苦于以下问题:Python VirtualMethods.virtualMethod0方法的具体用法?Python VirtualMethods.virtualMethod0怎么用?Python VirtualMethods.virtualMethod0使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sample.VirtualMethods
的用法示例。
在下文中一共展示了VirtualMethods.virtualMethod0方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testForInfiniteRecursion
# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
def testForInfiniteRecursion(self):
def myVirtualMethod0(obj, pt, val, cpx, b):
self.call_counter += 1
return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b)
vm = VirtualMethods()
vm.virtualMethod0 = types.MethodType(myVirtualMethod0, vm, VirtualMethods)
pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
vm.virtualMethod0(pt, val, cpx, b)
self.assertEqual(self.call_counter, 1)
示例2: testMonkeyPatchOnVirtualMethod
# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [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
示例3: testMonkeyPatchOnVirtualMethodWithInheritance
# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
def testMonkeyPatchOnVirtualMethodWithInheritance(self):
'''Injects new 'virtualMethod0' on an object that inherits from VirtualMethods and makes C++ call it.'''
duck = Duck()
pt, val, cpx, b = Point(1.1, 2.2), 4, complex(3.3, 4.4), True
result1 = duck.virtualMethod0(pt, val, cpx, b)
result2 = duck.callVirtualMethod0(pt, val, cpx, b)
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, 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
duck.virtualMethod0 = types.MethodType(myVirtualMethod0, duck, Duck)
result1 = duck.callVirtualMethod0(pt, val, cpx, b)
self.assert_(self.duck_method_called)
result2 = duck.virtualMethod0(pt, val, cpx, b)
self.assertEqual(result1, result2)
self.assertEqual(result1, VirtualMethods.virtualMethod0(duck, pt, val, cpx, b) * self.multiplier)
duck.virtualMethod0 = None
示例4: myVirtualMethod0
# 需要导入模块: from sample import VirtualMethods [as 别名]
# 或者: from sample.VirtualMethods import virtualMethod0 [as 别名]
def myVirtualMethod0(obj, pt, val, cpx, b):
self.duck_method_called = True
return VirtualMethods.virtualMethod0(obj, pt, val, cpx, b) * self.multiplier