From 8e40315258ed4a2e52e527168b0aff44c8942e62 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Thu, 8 May 2014 15:41:07 -0700 Subject: [PATCH] Helper test func for stopping OmniSharp server. --- .../ycm/server/tests/get_completions_test.py | 27 ++++--------------- python/ycm/server/tests/test_utils.py | 5 ++++ 2 files changed, 10 insertions(+), 22 deletions(-) diff --git a/python/ycm/server/tests/get_completions_test.py b/python/ycm/server/tests/get_completions_test.py index b92be09e..7cb6962e 100644 --- a/python/ycm/server/tests/get_completions_test.py +++ b/python/ycm/server/tests/get_completions_test.py @@ -22,7 +22,7 @@ SetUpPythonPath() import time import httplib from .test_utils import ( Setup, BuildRequest, PathToTestFile, - ChangeSpecificOptions ) + ChangeSpecificOptions, StopOmniSharpServer ) from webtest import TestApp, AppError from nose.tools import eq_, with_setup from hamcrest import ( assert_that, has_item, has_items, has_entry, @@ -89,12 +89,8 @@ def GetCompletions_CsCompleter_Works_test(): results = app.post_json( '/completions', completion_data ).json assert_that( results, has_items( CompletionEntryMatcher( 'CursorLeft' ), CompletionEntryMatcher( 'CursorSize' ) ) ) + StopOmniSharpServer( app ) - # We need to turn off the CS server so that it doesn't stick around - app.post_json( '/run_completer_command', - BuildRequest( completer_target = 'filetype_default', - command_arguments = ['StopServer'], - filetype = 'cs' ) ) @with_setup( Setup ) def GetCompletions_CsCompleter_ReloadSolutionWorks_test(): @@ -126,11 +122,7 @@ def GetCompletions_CsCompleter_ReloadSolutionWorks_test(): eq_(result, True) - # We need to turn off the CS server so that it doesn't stick around - app.post_json( '/run_completer_command', - BuildRequest( completer_target = 'filetype_default', - command_arguments = ['StopServer'], - filetype = 'cs' ) ) + StopOmniSharpServer( app ) @with_setup( Setup ) def GetCompletions_CsCompleter_StartsWithUnambiguousMultipleSolutions_test(): @@ -157,11 +149,7 @@ def GetCompletions_CsCompleter_StartsWithUnambiguousMultipleSolutions_test(): break time.sleep( 0.2 ) - # We need to turn off the CS server so that it doesn't stick around - app.post_json( '/run_completer_command', - BuildRequest( completer_target = 'filetype_default', - command_arguments = ['StopServer'], - filetype = 'cs' ) ) + StopOmniSharpServer( app ) @with_setup( Setup ) def GetCompletions_CsCompleter_DoesntStartWithAmbiguousMultipleSolutions_test(): @@ -195,12 +183,7 @@ def GetCompletions_CsCompleter_DoesntStartWithAmbiguousMultipleSolutions_test(): break time.sleep( 0.2 ) - # We need to turn off the CS server so that it doesn't stick around - app.post_json( '/run_completer_command', - BuildRequest( completer_target = 'filetype_default', - command_arguments = ['StopServer'], - filetype = 'cs' ) ) - + StopOmniSharpServer( app ) raise Exception( ('The Omnisharp server started, despite us not being able ' 'to find a suitable solution file to feed it. Did you ' 'fiddle with the solution finding code in ' diff --git a/python/ycm/server/tests/test_utils.py b/python/ycm/server/tests/test_utils.py index aa6bc197..0ef7ff37 100644 --- a/python/ycm/server/tests/test_utils.py +++ b/python/ycm/server/tests/test_utils.py @@ -75,3 +75,8 @@ def PathToTestFile( test_basename ): return os.path.join( PathToTestDataDir(), test_basename ) +def StopOmniSharpServer( app ): + app.post_json( '/run_completer_command', + BuildRequest( completer_target = 'filetype_default', + command_arguments = ['StopServer'], + filetype = 'cs' ) )