def test_static_instance_methods(self): from Merlin.Testing import Flag from Merlin.Testing.Delegate import ClassWithTargetMethods, VoidInt32Delegate, VoidSelfInt32Delegate target = ClassWithTargetMethods() x = VoidInt32Delegate(ClassWithTargetMethods.SMVoidInt32) x(2) Flag.Check(20) x = VoidSelfInt32Delegate(ClassWithTargetMethods.MVoidInt32) x(target, 3) Flag.Check(3) x = VoidInt32Delegate(target.SMVoidInt32) x(4) Flag.Check(40) x = VoidSelfInt32Delegate(target.MVoidInt32) self.assertRaises(TypeError, lambda: x(target, 5))
def test_interface_method(self): from Merlin.Testing.Delegate import InterfaceInt32Delegate, InterfaceWithTargetMethods, VoidInt32Delegate x = VoidInt32Delegate(InterfaceWithTargetMethods.MVoidInt32) self.assertRaisesMessage(TypeError, "MVoidInt32() takes exactly 2 arguments (1 given)", lambda: x(1)) # !!! x = InterfaceInt32Delegate(InterfaceWithTargetMethods.MVoidInt32) self.assertRaisesMessage(TypeError, "expected InterfaceWithTargetMethods, got NoneType", lambda: x(None, 2))