/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. from circuits import handler, Event, Component, Manager
  3. class test(Event):
  4. """test Event"""
  5. class App(Component):
  6. @handler("test")
  7. def test_0(self):
  8. return 0
  9. @handler("test", priority=3)
  10. def test_3(self):
  11. return 3
  12. @handler("test", priority=2)
  13. def test_2(self):
  14. return 2
  15. m = Manager()
  16. app = App()
  17. app.register(m)
  18. while m:
  19. m.flush()
  20. def test_main():
  21. v = m.fire(test())
  22. while m:
  23. m.flush()
  24. x = list(v)
  25. assert x == [3, 2, 0]