def test_reaction_decorator_fails(): class Foo: def foo(self, *events): pass f = Foo() def foo(*events): pass # Needs at least one argument with raises(TypeError): event.reaction() # Need a function with raises(TypeError): event.reaction('!foo')(3) # Need self argument with raises(TypeError): event.reaction('!foo')(foo) # Cannot be bound method with raises(TypeError): event.reaction('!foo')(f.foo)
def test_reaction_python_only(): m = MyObject1() # Reaction decorator needs proper callable and connection strings with raises(TypeError): event.reaction(3) with raises(TypeError): event.reaction(isinstance) # Check type of the instance attribute assert isinstance(m.r1, event._reaction.Reaction) # Cannot set or delete a reaction with raises(AttributeError): m.r1 = 3 with raises(AttributeError): del m.r1 # Repr and docs assert 'reaction' in repr(m.__class__.r1).lower() assert 'reaction' in repr(m.r1).lower() assert 'r1' in repr(m.r1)