#NEWLINE# def test_watch_file( self ) : #NEWLINE# #INDENT# watcher = Watcher ( ) #NEWLINE# watcher . count = 0 #NEWLINE# time . sleep ( 1 ) #NEWLINE# filepath = os . path . join ( tmpdir , 'foo' ) #NEWLINE# with open ( filepath , 'w' ) as f : #NEWLINE# #INDENT# f . write ( '' ) #NEWLINE# #UNINDENT# def add_count( ) : #NEWLINE# #INDENT# watcher . count += 1 #NEWLINE# #UNINDENT# watcher . watch ( filepath , add_count ) #NEWLINE# assert watcher . is_changed ( filepath ) #NEWLINE# time . sleep ( 1 ) #NEWLINE# with open ( filepath , 'w' ) as f : #NEWLINE# #INDENT# f . write ( '' ) #NEWLINE# #UNINDENT# rv = watcher . examine ( ) #NEWLINE# assert ( rv [ 0 ] == os . path . abspath ( filepath ) ) #NEWLINE# assert ( watcher . count == 1 )