From ec65950a9bc0986b28e8cda1dfdfae2e54b2ed79 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 9 May 2014 10:22:00 -0700 Subject: [PATCH] Fixing tests Tests read the default hmac_secret from default_settings.json, and that value is read as a unicode object by the json parser, not str. --- python/ycm/server/tests/get_completions_test.py | 10 ---------- python/ycm/utils.py | 3 ++- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/python/ycm/server/tests/get_completions_test.py b/python/ycm/server/tests/get_completions_test.py index 7cb6962e..9607dc36 100644 --- a/python/ycm/server/tests/get_completions_test.py +++ b/python/ycm/server/tests/get_completions_test.py @@ -173,16 +173,6 @@ def GetCompletions_CsCompleter_DoesntStartWithAmbiguousMultipleSolutions_test(): # the test passes if we caught an exception when trying to start it, # so raise one if it managed to start if not exception_caught: - # Now for some cleanup: wait for the server to start then shut it down - while True: - result = app.post_json( '/run_completer_command', - BuildRequest( completer_target = 'filetype_default', - command_arguments = ['ServerRunning'], - filetype = 'cs' ) ).json - if result: - break - time.sleep( 0.2 ) - StopOmniSharpServer( app ) raise Exception( ('The Omnisharp server started, despite us not being able ' 'to find a suitable solution file to feed it. Did you ' diff --git a/python/ycm/utils.py b/python/ycm/utils.py index f320ca1a..b557dc04 100644 --- a/python/ycm/utils.py +++ b/python/ycm/utils.py @@ -219,7 +219,8 @@ def ContentHexHmacValid( content, hmac, hmac_secret ): def CreateHexHmac( content, hmac_secret ): - return hmac.new( hmac_secret, + # Must ensure that hmac_secret is str and not unicode + return hmac.new( str( hmac_secret ), msg = content, digestmod = hashlib.sha256 ).hexdigest()