<s> """<STR_LIT>""" <EOL> import unittest <EOL> import coro <EOL> from coro . test import coro_unittest <EOL> class Test ( unittest . TestCase ) : <EOL> shared = None <EOL> t1_cv = None <EOL> t2_cv = None <EOL> def t1 ( self ) : <EOL> self . assertFalse ( hasattr ( self . shared , '<STR_LIT:x>' ) ) <EOL> self . assertRaises ( AttributeError , lambda : self . shared . x ) <EOL> self . t1_cv . wait ( ) <EOL> self . assertFalse ( hasattr ( self . shared , '<STR_LIT:x>' ) ) <EOL> self . assertRaises ( AttributeError , lambda : self . shared . x ) <EOL> self . shared . x = <NUM_LIT:2> <EOL> self . t1_cv . wait ( ) <EOL> self . assertEqual ( self . shared . x , <NUM_LIT:2> ) <EOL> def t2 ( self ) : <EOL> self . assertFalse ( hasattr ( self . shared , '<STR_LIT:x>' ) ) <EOL> self . assertRaises ( AttributeError , lambda : self . shared . x ) <EOL> self . t2_cv . wait ( ) <EOL> self . assertFalse ( hasattr ( self . shared , '<STR_LIT:x>' ) ) <EOL> self . assertRaises ( AttributeError , lambda : self . shared . x ) <EOL> self . shared . x = <NUM_LIT:3> <EOL> self . t2_cv . wait ( ) <EOL> self . assertEqual ( self . shared . x , <NUM_LIT:3> ) <EOL> def test_local ( self ) : <EOL> """<STR_LIT>""" <EOL> self . t1_cv = coro . condition_variable ( ) <EOL> self . t2_cv = coro . condition_variable ( ) <EOL> self . shared = coro . ThreadLocal ( ) <EOL> self . shared . x = <NUM_LIT:1> <EOL> t1 = coro . spawn ( self . t1 ) <EOL> t2 = coro . spawn ( self . t2 ) <EOL> coro . yield_slice ( ) <EOL> self . t1_cv . wake_one ( ) <EOL> coro . yield_slice ( ) <EOL> self . assertEqual ( self . shared . x , <NUM_LIT:1> ) <EOL> self . t2_cv . wake_one ( ) <EOL> coro . yield_slice ( ) <EOL> self . assertEqual ( self . shared . x , <NUM_LIT:1> ) <EOL> self . t1_cv . wake_one ( ) <EOL> self . t2_cv . wake_one ( ) <EOL> coro . yield_slice ( ) <EOL> t1 . join ( ) <EOL> t2 . join ( ) <EOL> self . assertEqual ( self . shared . x , <NUM_LIT:1> ) <EOL> del self . shared <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> coro_unittest . run_tests ( ) </s>
