/tests/core/test_filters.py

https://bitbucket.org/prologic/circuits/ · Python · 29 lines · 18 code · 9 blank · 2 comment · 3 complexity · 43e221327836289b2cc775439038a4a1 MD5 · raw file

  1. #!/usr/bin/env python
  2. from circuits import handler, Event, BaseComponent
  3. class test(Event):
  4. """test Event"""
  5. class App(BaseComponent):
  6. @handler("test")
  7. def _on_test(self, event):
  8. try:
  9. return "Hello World!"
  10. finally:
  11. event.stop()
  12. def _on_test2(self):
  13. pass # Never reached
  14. def test_main():
  15. app = App()
  16. while app:
  17. app.flush()
  18. x = app.fire(test())
  19. app.flush()
  20. assert x.value == "Hello World!"