PageRenderTime 58ms CodeModel.GetById 53ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/core/test_priority.py

https://bitbucket.org/prologic/circuits/
Python | 37 lines | 23 code | 12 blank | 2 comment | 2 complexity | 979eeec1c6d0fd02211ef9adf1c9b4d6 MD5 | raw file
 1#!/usr/bin/python -i
 2
 3from circuits import handler, Event, Component, Manager
 4
 5
 6class test(Event):
 7    """test Event"""
 8
 9
10class App(Component):
11
12    @handler("test")
13    def test_0(self):
14        return 0
15
16    @handler("test", priority=3)
17    def test_3(self):
18        return 3
19
20    @handler("test", priority=2)
21    def test_2(self):
22        return 2
23
24m = Manager()
25app = App()
26app.register(m)
27
28while m:
29    m.flush()
30
31
32def test_main():
33    v = m.fire(test())
34    while m:
35        m.flush()
36    x = list(v)
37    assert x == [3, 2, 0]