#NEWLINE# def test_multiple_config_changes( self ) : #NEWLINE# #INDENT# '\n        When monitored file is changed multiple times, the callback\n        should be invoked every time.\n        ' #NEWLINE# ( fd , tmp_file ) = tempfile . mkstemp ( ) #NEWLINE# test_data = [ 0 , None , None ] #NEWLINE# def on_change( value , stat ) : #NEWLINE# #INDENT# test_data [ 0 ] += 1 #NEWLINE# test_data [ 1 ] = value #NEWLINE# test_data [ 2 ] = stat . version #NEWLINE# #UNINDENT# new_content = 'hello' #NEWLINE# watch = FileWatch ( polling = False ) #NEWLINE# watch . _clear_all_watches ( ) #NEWLINE# self . _validate_empty_internal_map ( watch ) #NEWLINE# watch . add_watch ( tmp_file , on_change ) #NEWLINE# self . _validate_internal_map ( watch , tmp_file , 'config' , 1 ) #NEWLINE# times = 3 #NEWLINE# expected_content = '' #NEWLINE# for i in range ( times ) : #NEWLINE# #INDENT# time . sleep ( 1 ) #NEWLINE# new_line = ( ( new_content + str ( i ) ) + '\n' ) #NEWLINE# f = open ( tmp_file , 'a' ) #NEWLINE# f . write ( new_line ) #NEWLINE# f . close ( ) #NEWLINE# watch . _check_file_updates ( ) #NEWLINE# self . _validate_internal_map ( watch , tmp_file , 'config' , 1 ) #NEWLINE# expected_content += new_line #NEWLINE# self . assertEqual ( test_data [ 0 ] , ( i + 2 ) ) #NEWLINE# self . assertEqual ( test_data [ 1 ] , expected_content ) #NEWLINE# self . assertEqual ( test_data [ 2 ] , os . path . getmtime ( tmp_file ) ) #NEWLINE# #UNINDENT# del watch #NEWLINE# os . remove ( tmp_file )