/tests/core/test_generator_value.py

https://bitbucket.org/prologic/circuits/ · Python · 51 lines · 31 code · 17 blank · 3 comment · 3 complexity · 9af93e21990abab00f05df4680c9eb40 MD5 · raw file

  1. #!/usr/bin/env python
  2. from circuits import Event, Component
  3. class test(Event):
  4. """test Event"""
  5. class hello(Event):
  6. """hello Event"""
  7. class App(Component):
  8. def test(self):
  9. def f():
  10. while True:
  11. yield "Hello"
  12. return f()
  13. def hello(self):
  14. yield "Hello "
  15. yield "World!"
  16. def test_return_generator():
  17. app = App()
  18. while app:
  19. app.flush()
  20. v = app.fire(test())
  21. app.tick()
  22. app.tick()
  23. x = v.value
  24. assert x == "Hello"
  25. def test_yield():
  26. app = App()
  27. while app:
  28. app.flush()
  29. v = app.fire(hello())
  30. app.tick()
  31. app.tick()
  32. app.tick()
  33. x = v.value
  34. assert x == ["Hello ", "World!"]