/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
- #!/usr/bin/env python
- from circuits import Event, Component
- class test(Event):
- """test Event"""
- class hello(Event):
- """hello Event"""
- class App(Component):
- def test(self):
- def f():
- while True:
- yield "Hello"
- return f()
- def hello(self):
- yield "Hello "
- yield "World!"
- def test_return_generator():
- app = App()
- while app:
- app.flush()
- v = app.fire(test())
- app.tick()
- app.tick()
- x = v.value
- assert x == "Hello"
- def test_yield():
- app = App()
- while app:
- app.flush()
- v = app.fire(hello())
- app.tick()
- app.tick()
- app.tick()
- x = v.value
- assert x == ["Hello ", "World!"]