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)
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)
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.6+ or 3.3+. " "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.6+ or 3.3+. " "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 )