def Wrapper(test_case_instance, *args, **kwargs): with UserOptions(custom_options): ycm = YouCompleteMe() WaitUntilReady() ycm.CheckIfServerIsReady() try: test_utils.VIM_PROPS_FOR_BUFFER.clear() return test(test_case_instance, ycm, *args, **kwargs) finally: StopServer(ycm)
def SetUpYCM(): from ycm import base from ycmd import user_options_store from ycm.youcompleteme import YouCompleteMe base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) return YouCompleteMe(user_options_store.GetAll())
def HasCompletionsThatCouldBeCompletedWithMoreText_OldVim_NonMatchIsntReturned_test( ): ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) vimsupport.VimVersionAtLeast = MagicMock(return_value=False) vimsupport.TextBeforeCursor = MagicMock(return_value=" Quote") completions = [_BuildCompletion("A")] result = ycm_state._HasCompletionsThatCouldBeCompletedWithMoreText( completions) eq_(result, False)
def ycm(request): custom_options = request.param with UserOptions(custom_options): ycm = YouCompleteMe() WaitUntilReady() ycm.CheckIfServerIsReady() try: test_utils.VIM_MATCHES_FOR_WINDOW.clear() yield ycm finally: StopServer(ycm)
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_NonMatchIsntReturned_test( ): ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) vimsupport.VimVersionAtLeast = MagicMock(return_value=True) vimsupport.GetVariableValue = GetVariableValue_CompleteItemIs(" Quote") completions = [_BuildCompletion("A")] result = ycm_state._HasCompletionsThatCouldBeCompletedWithMoreText( completions) eq_(result, False)
def youcompleteme_instance(custom_options={}): """Defines a context manager to be used in case a shared YCM state between subtests is to be avoided, as could be the case with completion caching.""" with UserOptions(custom_options): ycm = YouCompleteMe() WaitUntilReady() try: test_utils.VIM_PROPS_FOR_BUFFER.clear() yield ycm finally: StopServer(ycm)
def SetUpYCM(): from ycm import base, paths from ycmd import user_options_store, utils from ycm.youcompleteme import YouCompleteMe base.LoadJsonDefaultsIntoVim() user_options_store.SetAll(base.BuildServerConf()) popen_args = [ paths.PathToPythonInterpreter(), paths.PathToCheckCoreVersion() ] if utils.SafePopen(popen_args).wait() == 2: raise RuntimeError('YCM support libs too old, PLEASE RECOMPILE.') return YouCompleteMe(user_options_store.GetAll())
def YouCompleteMe_NoPythonInterpreterFound_test( post_vim_message, *args ): try: with patch( 'ycmd.utils.ReadFile', side_effect = IOError ): ycm = YouCompleteMe( MakeUserOptions() ) assert_that( ycm.IsServerAlive(), equal_to( False ) ) post_vim_message.assert_called_once_with( "Unable to start the ycmd server. Cannot find Python 2.7 or 3.4+. " "Set the 'g:ycm_server_python_interpreter' option to a Python " "interpreter path. " "Correct the error then restart the server with ':YcmRestartServer'." ) post_vim_message.reset_mock() with patch( 'ycm.tests.test_utils.server_python_interpreter', _PathToPythonUsedDuringBuild() ): ycm.RestartServer() assert_that( ycm.IsServerAlive(), equal_to( True ) ) post_vim_message.assert_called_once_with( 'Restarting ycmd server...' ) finally: WaitUntilReady() StopServer( ycm )
def YouCompleteMe_InvalidPythonInterpreterPath_test( post_vim_message ): try: with patch( 'ycm.tests.test_utils.server_python_interpreter', '/invalid/path/to/python' ): ycm = YouCompleteMe( MakeUserOptions() ) assert_that( ycm.IsServerAlive(), equal_to( False ) ) post_vim_message.assert_called_once_with( "Unable to start the ycmd server. " "Path in 'g:ycm_server_python_interpreter' option does not point " "to a valid Python 2.7 or 3.4+. " "Correct the error then restart the server with ':YcmRestartServer'." ) post_vim_message.reset_mock() with patch( 'ycm.tests.test_utils.server_python_interpreter', _PathToPythonUsedDuringBuild() ): ycm.RestartServer() assert_that( ycm.IsServerAlive(), equal_to( True ) ) post_vim_message.assert_called_once_with( 'Restarting ycmd server...' ) finally: WaitUntilReady() StopServer( ycm )
def GetCompleteDoneHooks_EmptyOnOtherFiletype_test(): vimsupport.CurrentFiletypes = MagicMock(return_value=["txt"]) ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) result = ycm_state.GetCompleteDoneHooks() eq_(0, len(list(result)))
def setUp( self ): self.ycm = YouCompleteMe( MagicMock( spec_set = dict ) )
def GetCompleteDoneHooks_ResultOnCsharp_test( *args ): ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) ) result = ycm_state.GetCompleteDoneHooks() eq_( 1, len( list( result ) ) )
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_ShortTextDoesntRaise_test( *args ): ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) ) completions = [ _BuildCompletion( "AAA" ) ] ycm_state._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
def GetCompleteDoneHooks_EmptyOnOtherFiletype_test( *args ): ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) ) result = ycm_state.GetCompleteDoneHooks() eq_( 0, len( list( result ) ) )
def setUp(self): with patch('vim.eval', side_effect=self.VimEval): user_options_store.SetAll(base.BuildServerConf()) self.ycm = YouCompleteMe(user_options_store.GetAll())
def setUp(self): # We need a server instance for FilterAndSortCandidates self._server_state = YouCompleteMe(MakeUserOptions())
def OnCompleteDone_NoActionNoError_test( *args ): ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) ) ycm_state.OnCompleteDone()
def OnCompleteDone_NoActionNoError_test(): vimsupport.CurrentFiletypes = MagicMock(return_value=["txt"]) ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) ycm_state.OnCompleteDone()
def FilterToCompletedCompletions_OldVim_ShortTextDoesntRaise_test( *args ): ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) ) completions = [ _BuildCompletion( "AAA" ) ] ycm_state._FilterToMatchingCompletions( completions, False )
def GetCompleteDoneHooks_ResultOnCsharp_test(): vimsupport.CurrentFiletypes = MagicMock(return_value=["cs"]) ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) result = ycm_state.GetCompleteDoneHooks() eq_(1, len(list(result)))
def GetRequiredNamespaceImport_ReturnNamespaceFromExtraData_test(): namespace = "A_NAMESPACE" ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) eq_(namespace, ycm_state._GetRequiredNamespaceImport(_BuildCompletion(namespace)))
def GetRequiredNamespaceImport_ReturnNoneForNoExtraData_test(): ycm_state = YouCompleteMe(MagicMock(spec_set=dict)) eq_(None, ycm_state._GetRequiredNamespaceImport({}))