#NEWLINE# def test_add_config_monitor( self ) : #NEWLINE# #INDENT# '\n        When adding a monitor, the callback should be invoked.\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# watch = FileWatch ( polling = False ) #NEWLINE# watch . _clear_all_watches ( ) #NEWLINE# self . _validate_empty_internal_map ( fd ) #NEWLINE# watch . add_watch ( tmp_file , on_change ) #NEWLINE# self . _validate_internal_map ( watch , tmp_file , 'config' , 1 ) #NEWLINE# self . assertEqual ( test_data [ 0 ] , 1 ) #NEWLINE# self . assertEqual ( test_data [ 1 ] , '' ) #NEWLINE# self . assertEqual ( test_data [ 2 ] , os . path . getmtime ( tmp_file ) ) #NEWLINE# del watch #NEWLINE# os . remove ( tmp_file )