#NEWLINE# @ destructiveTest #NEWLINE# def test_dir_auto_add( self , * args , **kwargs ) : #NEWLINE# #INDENT# tmpdir = None #NEWLINE# try : #NEWLINE# #INDENT# tmpdir = tempfile . mkdtemp ( ) #NEWLINE# config = { #NEWLINE# #INDENT# tmpdir : { #NEWLINE# #INDENT# 'mask' : [ 'create' , 'open' ] , #NEWLINE# 'auto_add' : True , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# ret = inotify . beacon ( config ) #NEWLINE# self . assertEqual ( ret , [ ] ) #NEWLINE# fp = os . path . join ( tmpdir , 'tmpfile' ) #NEWLINE# with open ( fp , 'w' ) as f : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ret = inotify . beacon ( config ) #NEWLINE# self . assertEqual ( len ( ret ) , 2 ) #NEWLINE# self . assertEqual ( ret [ 0 ] [ 'path' ] , fp ) #NEWLINE# self . assertEqual ( ret [ 0 ] [ 'change' ] , 'IN_CREATE' ) #NEWLINE# self . assertEqual ( ret [ 1 ] [ 'path' ] , fp ) #NEWLINE# self . assertEqual ( ret [ 1 ] [ 'change' ] , 'IN_OPEN' ) #NEWLINE# with open ( fp , 'r' ) as f : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# ret = inotify . beacon ( config ) #NEWLINE# self . assertEqual ( len ( ret ) , 1 ) #NEWLINE# self . assertEqual ( ret [ 0 ] [ 'path' ] , fp ) #NEWLINE# self . assertEqual ( ret [ 0 ] [ 'change' ] , 'IN_OPEN' ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# if tmpdir : #NEWLINE# #INDENT# shutil . rmtree ( tmpdir )