PageRenderTime 15ms CodeModel.GetById 10ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/core/test_all_channels.py

https://bitbucket.org/prologic/circuits/
Python | 40 lines | 22 code | 11 blank | 7 comment | 3 complexity | 5600bc56df276ce666f76d9635c6a0f0 MD5 | raw file
 1# Module:   test_all_channels
 2# Date:     23rd February 2010
 3# Author:   James Mills, prologic at shortcircuit dot net dot au
 4
 5"""All Channels Tests
 6
 7Test that events can be sent to all channels.
 8"""
 9
10from circuits import Event, Component, Manager
11
12class Base(Component):
13
14    def __init__(self, *args, **kwargs):
15        super(Base, self).__init__(*args, **kwargs)
16
17        self.flag = False
18
19    def foo(self, event, *args, **kwargs):
20        self.flag = True
21
22def test():
23    m = Manager()
24    a = Base(channel="a")
25    b = Base(channel="b")
26    c = Base()
27
28    a.register(m)
29    b.register(m)
30    c.register(m)
31
32    while m:
33        m.flush()
34
35    m.fire(Event(), "*")
36    m.flush()
37
38    assert not a.flag
39    assert not b.flag
40    assert c.flag