#NEWLINE# @ mock . patch ( 'oauth2client.contrib.locked_file.open' , create = True ) #NEWLINE# @ mock . patch ( 'oauth2client.contrib.locked_file.logger' ) #NEWLINE# @ mock . patch ( 'time.time' ) #NEWLINE# def test_lock_timeout_error_no_fh( self , mock_time , mock_logger , mock_open ) : #NEWLINE# #INDENT# ( instance , _ ) = self . _make_one ( ) #NEWLINE# mock_time . side_effect = [ 0 , 10 ] #NEWLINE# fh_mock = mock . Mock ( ) #NEWLINE# mock_open . side_effect = [ IOError ( errno . ENOENT , '' ) , fh_mock ] #NEWLINE# with mock . patch ( 'os.open' ) as mock_os_open : #NEWLINE# #INDENT# mock_os_open . side_effect = [ OSError ( errno . EEXIST , '' ) ] #NEWLINE# instance . open_and_lock ( 1 , 1 ) #NEWLINE# self . assertFalse ( instance . is_locked ( ) ) #NEWLINE# self . assertTrue ( mock_logger . warn . called ) #NEWLINE# self . assertEqual ( instance . file_handle ( ) , fh_mock )