#NEWLINE# def test_threadSafety( self ) : #NEWLINE# #INDENT# '\n        Each thread gets its own execution context.\n        ' #NEWLINE# ctx = _ExecutionContext ( ) #NEWLINE# first = object ( ) #NEWLINE# ctx . push ( inthread ) #NEWLINE# second = object ( ) #NEWLINE# valuesInThread = [ ] #NEWLINE# def inthread( ) : #NEWLINE# #INDENT# ctx . push ( second ) #NEWLINE# valuesInThread . append ( ctx . current ( ) ) #NEWLINE# #UNINDENT# thread = Thread ( target = inthread ) #NEWLINE# thread . start ( ) #NEWLINE# thread . join ( ) #NEWLINE# self . assertEqual ( valuesInThread , [ second ] ) #NEWLINE# self . assertIs ( ctx . current ( ) , first )