#NEWLINE# def test_multi_thread_change_event_recorder( self ) : #NEWLINE# #INDENT# test_object = TestObject ( ) #NEWLINE# container = MultiThreadRecordContainer ( ) #NEWLINE# recorder = MultiThreadChangeEventRecorder ( container = container ) #NEWLINE# trait_notifiers . set_change_event_tracers ( pre_tracer = recorder . pre_tracer , post_tracer = recorder . post_tracer ) #NEWLINE# try : #NEWLINE# #INDENT# test_object . number = 5.0 #NEWLINE# thread = threading . Thread ( target = test_object . add_to_number , args = ( 5 , ) ) #NEWLINE# thread . start ( ) #NEWLINE# thread . join ( ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# trait_notifiers . clear_change_event_tracers ( ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( container . _record_containers ) , 2 ) #NEWLINE# container . save_to_directory ( lines . directory ) #NEWLINE# for name in container . _record_containers : #NEWLINE# #INDENT# filename = os . path . join ( self . directory , '{0}.trace' . format ( name ) ) #NEWLINE# with open ( filename , 'r' ) as handle : #NEWLINE# #INDENT# lines = handle . readlines ( ) #NEWLINE# #UNINDENT# self . assertEqual ( len ( lines ) , 4 ) #NEWLINE# if ( 'MainThread.trace' in filename ) : #NEWLINE# #INDENT# self . assertTrue ( ( "-> 'number' changed from 2.0 to 5.0 in 'TestObject'\n" in lines [ 0 ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . assertTrue ( ( "-> 'number' changed from 5.0 to 10.0 in 'TestObject'\n" in lines [ 0 ] ) ) #NEWLINE# #UNINDENT# self . assertTrue ( ( 'CALLING' in lines [ 1 ] ) ) #NEWLINE# self . assertTrue ( ( 'EXIT' in lines [ 2 ] ) )