def test_add_method_descriptor(self): from Merlin.Testing import Flag from Merlin.Testing.Event import ClassWithSimpleEvent, TargetClass x = ClassWithSimpleEvent() x.OnAction += TargetClass.s_Negate x.OnAction += TargetClass.i_Double # method Flag.Set(0) self.assertRaisesMessage( TypeError, "i_Double() takes exactly 2 arguments (1 given)", lambda: x.CallInside(4)) Flag.Check(10)
def test_assignment(self): from Merlin.Testing.Event import ClassWithSimpleEvent, TargetClass x = ClassWithSimpleEvent() # 362440 def f(): x.OnAction = TargetClass.s_Double self.assertRaisesMessage( AttributeError, "attribute 'OnAction' of 'ClassWithSimpleEvent' object is read-only", f)
def test_add_sub(self): from Merlin.Testing.Event import ClassWithSimpleEvent, TargetClass x = ClassWithSimpleEvent() def f(): x.OnAction = x.OnAction + TargetClass.s_Negate self.assertRaisesMessage( TypeError, "unsupported operand type(s) for +: 'BoundEvent' and 'builtin_function_or_method'", f) def f(): x.OnAction - TargetClass.s_Negate self.assertRaisesMessage( TypeError, "unsupported operand type(s) for -: 'BoundEvent' and 'builtin_function_or_method'", f)
def test_call_outside(self): from Merlin.Testing.Event import ClassWithSimpleEvent, TargetClass x = ClassWithSimpleEvent() x.OnAction += TargetClass.s_Negate
def test_iadd_isub(self): from Merlin.Testing.Event import ClassWithSimpleEvent x = ClassWithSimpleEvent()