<s> import pytest <EOL> from circuits import Component , Event <EOL> class App ( Component ) : <EOL> def init ( self ) : <EOL> self . _ready = False <EOL> self . _done = False <EOL> self . _counter = <NUM_LIT:0> <EOL> def registered ( self , component , manager ) : <EOL> if component is self : <EOL> self . fire ( Event . create ( "<STR_LIT>" ) ) <EOL> def generate_events ( self , event ) : <EOL> if not self . _ready or self . _done : <EOL> return <EOL> if self . _counter < <NUM_LIT:10> : <EOL> self . fire ( Event . create ( "<STR_LIT:hello>" ) ) <EOL> else : <EOL> self . fire ( Event . create ( "<STR_LIT>" ) ) <EOL> event . reduce_time_left ( <NUM_LIT:0> ) <EOL> def done ( self ) : <EOL> self . _done = True <EOL> def hello ( self ) : <EOL> self . _counter += <NUM_LIT:1> <EOL> def ready ( self ) : <EOL> self . _ready = True <EOL> @ pytest . fixture <EOL> def app ( request , manager , watcher ) : <EOL> app = App ( ) . register ( manager ) <EOL> def finalizer ( ) : <EOL> app . unregister ( ) <EOL> request . addfinalizer ( finalizer ) <EOL> assert watcher . wait ( "<STR_LIT>" ) <EOL> return app <EOL> def test ( manager , watcher , app ) : <EOL> watcher . wait ( "<STR_LIT>" ) <EOL> assert app . _counter == <NUM_LIT:10> </s>
