<s> import unittest <EOL> from eventlet . event import Event <EOL> from eventlet . api import spawn , sleep , with_timeout <EOL> import eventlet <EOL> from tests import LimitedTestCase <EOL> DELAY = <NUM_LIT> <EOL> class TestEvent ( LimitedTestCase ) : <EOL> def test_send_exc ( self ) : <EOL> log = [ ] <EOL> e = Event ( ) <EOL> def waiter ( ) : <EOL> try : <EOL> result = e . wait ( ) <EOL> log . append ( ( '<STR_LIT>' , result ) ) <EOL> except Exception , ex : <EOL> log . append ( ( '<STR_LIT>' , ex ) ) <EOL> spawn ( waiter ) <EOL> sleep ( <NUM_LIT:0> ) <EOL> obj = Exception ( ) <EOL> e . send ( exc = obj ) <EOL> sleep ( <NUM_LIT:0> ) <EOL> sleep ( <NUM_LIT:0> ) <EOL> assert log == [ ( '<STR_LIT>' , obj ) ] , log <EOL> def test_send ( self ) : <EOL> event1 = Event ( ) <EOL> event2 = Event ( ) <EOL> spawn ( event1 . send , '<STR_LIT>' ) <EOL> eventlet . Timeout ( <NUM_LIT:0> , ValueError ( '<STR_LIT>' ) ) <EOL> try : <EOL> result = event1 . wait ( ) <EOL> except ValueError : <EOL> X = object ( ) <EOL> result = with_timeout ( DELAY , event2 . wait , timeout_value = X ) <EOL> assert result is X , '<STR_LIT>' % ( result , ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
