#NEWLINE# def setUp( self ) : #NEWLINE# #INDENT# super ( LsLogsTestCase , self ) . setUp ( ) #NEWLINE# self . mock_fs = Mock ( ) #NEWLINE# self . mock_paths = [ ] #NEWLINE# def mock_fs_ls( log_dir ) : #NEWLINE# #INDENT# prefix = ( log_dir . rstrip ( '/' ) + '/' ) #NEWLINE# exists = False #NEWLINE# for p in self . mock_paths : #NEWLINE# #INDENT# if isinstance ( p , Exception ) : #NEWLINE# #INDENT# raise p #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if p . startswith ( prefix ) : #NEWLINE# #INDENT# ( yield p ) #NEWLINE# exists = True #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( not exists ) : #NEWLINE# #INDENT# raise IOError #NEWLINE# #UNINDENT# #UNINDENT# def mock_fs_exists( log_dir ) : #NEWLINE# #INDENT# return any ( mock_fs_ls ( log_dir ) ) #NEWLINE# #UNINDENT# self . mock_fs . ls = Mock ( side_effect = mock_fs_ls ) #NEWLINE# self . mock_fs . exists = Mock ( side_effect = self ) #NEWLINE# def mock_matcher( path , **kwargs ) : #NEWLINE# #INDENT# return dict ( ** kwargs ) #NEWLINE# #UNINDENT# self . mock_matcher = Mock ( side_effect = mock_matcher )