Esempio n. 1
0
 def test_pyevent_named_dispatch(self):
     plugins = PyPlugins()
     l = []
     class A:
         def pyevent_name(self, x): 
             l.append(x)
     plugins.register(A())
     plugins.notify("name", 13)
     assert l == [13]
Esempio n. 2
0
    def test_pyevent_anonymous_dispatch(self):
        plugins = PyPlugins()
        l = []
        class A:
            def pyevent(self, name, *args, **kwargs): 
                if name == "name":
                    l.extend([args, kwargs])

        plugins.register(A())
        plugins.notify("name", 13, x=15)
        assert l == [(13, ), {'x':15}]
Esempio n. 3
0
 def test_notify_anonymous_ordered(self):
     plugins = PyPlugins()
     l = []
     class api1:
         def pyevent_hello(self): 
             l.append("hellospecific")
     class api2:
         def pyevent(self, name, *args): 
             if name == "hello":
                 l.append(name + "anonymous") 
     plugins.register(api1())
     plugins.register(api2())
     plugins.notify('hello')
     assert l == ["hellospecific", "helloanonymous"]