PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/tests/core/test_filters.py

https://bitbucket.org/prologic/circuits/
Python | 29 lines | 18 code | 9 blank | 2 comment | 1 complexity | 43e221327836289b2cc775439038a4a1 MD5 | raw file
 1#!/usr/bin/env python
 2
 3from circuits import handler, Event, BaseComponent
 4
 5
 6class test(Event):
 7    """test Event"""
 8
 9
10class App(BaseComponent):
11
12    @handler("test")
13    def _on_test(self, event):
14        try:
15            return "Hello World!"
16        finally:
17            event.stop()
18
19    def _on_test2(self):
20        pass  # Never reached
21
22
23def test_main():
24    app = App()
25    while app:
26        app.flush()
27    x = app.fire(test())
28    app.flush()
29    assert x.value == "Hello World!"