Пример #1
0
def YouCompleteMe_NoPythonInterpreterFound_test(post_vim_message, *args):
    with UserOptions({}):
        try:
            with patch('ycmd.utils.ReadFile', side_effect=IOError):
                ycm = YouCompleteMe()

            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()

            SetVariableValue('g:ycm_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)
Пример #2
0
def YouCompleteMe_InvalidPythonInterpreterPath_test(post_vim_message):
    with UserOptions(
        {'g:ycm_server_python_interpreter': '/invalid/python/path'}):
        try:
            ycm = YouCompleteMe()

            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()

            SetVariableValue('g:ycm_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)
Пример #3
0
 def test_DontTruncateIfNotPopup(self, *args):
     with UserOptions({'&columns': 60, '&completeopt': b'preview,menuone'}):
         extra_data = {
             'doc_string': 'DOC STRING',
         }
         self._Check(
             {
                 'insertion_text': '',
                 'menu_text': 'MENU TEXT',
                 'extra_menu_info':
                 'ESPECIALLY LONG EXTRA MENU INFO LOREM IPSUM DOLOR',
                 'kind': 'K',
                 'detailed_info': 'DETAILED INFO',
                 'extra_data': extra_data,
             }, {
                 'word': '',
                 'abbr': 'MENU TEXT',
                 'menu':
                 'ESPECIALLY LONG EXTRA MENU INFO LOREM IPSUM DOLOR',
                 'kind': 'k',
                 'info': 'DETAILED INFO\nDOC STRING',
                 'equal': 1,
                 'dup': 1,
                 'empty': 1,
                 'user_data': json.dumps(extra_data),
             })
Пример #4
0
 def test_TruncateForPopupWithoutDuplication(self, *args):
     with UserOptions({'&columns': 60, '&completeopt': b'popup,menuone'}):
         extra_data = {
             'doc_string': 'DOC STRING',
         }
         self._Check(
             {
                 'insertion_text': '',
                 'menu_text': 'MENU TEXT',
                 'extra_menu_info':
                 'ESPECIALLY LONG METHOD SIGNATURE LOREM IPSUM',
                 'kind': 'K',
                 'detailed_info':
                 'ESPECIALLY LONG METHOD SIGNATURE LOREM IPSUM',
                 'extra_data': extra_data,
             }, {
                 'word': '',
                 'abbr': 'MENU TEXT',
                 'menu': 'ESPECIALLY LONG M...',
                 'kind': 'k',
                 'info': 'ESPECIALLY LONG METHOD SIGNATURE LOREM IPSUM\n' +
                 'DOC STRING',
                 'equal': 1,
                 'dup': 1,
                 'empty': 1,
                 'user_data': json.dumps(extra_data),
             })
Пример #5
0
 def test_OnlyTruncateForPopupIfNecessary(self, *args):
     with UserOptions({'&columns': 60, '&completeopt': b'popup,menuone'}):
         extra_data = {
             'doc_string': 'DOC STRING',
         }
         self._Check(
             {
                 'insertion_text': '',
                 'menu_text': 'MENU TEXT',
                 'extra_menu_info': 'EXTRA MENU INFO',
                 'kind': 'K',
                 'detailed_info': 'DETAILED INFO',
                 'extra_data': extra_data,
             }, {
                 'word': '',
                 'abbr': 'MENU TEXT',
                 'menu': 'EXTRA MENU INFO',
                 'kind': 'k',
                 'info': 'DETAILED INFO\nDOC STRING',
                 'equal': 1,
                 'dup': 1,
                 'empty': 1,
                 'user_data': json.dumps(extra_data),
             })