예제 #1
0
 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)
예제 #2
0
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)
예제 #4
0
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)
예제 #6
0
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)
예제 #7
0
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())
예제 #8
0
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 )
예제 #9
0
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)))
예제 #11
0
 def setUp( self ):
   self.ycm = YouCompleteMe( MagicMock( spec_set = dict ) )
예제 #12
0
def GetCompleteDoneHooks_ResultOnCsharp_test( *args ):
  ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) )
  result = ycm_state.GetCompleteDoneHooks()
  eq_( 1, len( list( result ) ) )
예제 #13
0
def HasCompletionsThatCouldBeCompletedWithMoreText_NewVim_ShortTextDoesntRaise_test( *args ):
  ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) )
  completions = [ _BuildCompletion( "AAA" ) ]

  ycm_state._HasCompletionsThatCouldBeCompletedWithMoreText( completions )
예제 #14
0
def GetCompleteDoneHooks_EmptyOnOtherFiletype_test( *args ):
  ycm_state = YouCompleteMe( MagicMock( spec_set = dict ) )
  result = ycm_state.GetCompleteDoneHooks()
  eq_( 0, len( list( result ) ) )
예제 #15
0
 def setUp(self):
     with patch('vim.eval', side_effect=self.VimEval):
         user_options_store.SetAll(base.BuildServerConf())
         self.ycm = YouCompleteMe(user_options_store.GetAll())
예제 #16
0
 def setUp(self):
     # We need a server instance for FilterAndSortCandidates
     self._server_state = YouCompleteMe(MakeUserOptions())
예제 #17
0
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()
예제 #19
0
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({}))