From 2afc0d5f5f51811ca379be4f1a4e3cf904860828 Mon Sep 17 00:00:00 2001 From: micbou Date: Thu, 6 Jul 2017 19:43:34 +0200 Subject: [PATCH 1/2] Update BufferUnload test with Unicode paths --- python/ycm/tests/event_notification_test.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/ycm/tests/event_notification_test.py b/python/ycm/tests/event_notification_test.py index 716703bc..ca65f22b 100644 --- a/python/ycm/tests/event_notification_test.py +++ b/python/ycm/tests/event_notification_test.py @@ -25,7 +25,8 @@ from __future__ import absolute_import from builtins import * # noqa from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock, - MockVimBuffers, MockVimModule, VimBuffer ) + MockVimBuffers, MockVimModule, VimBuffer, + ToBytesOnPY2 ) MockVimModule() import contextlib @@ -447,14 +448,14 @@ def EventNotification_BufferVisit_BuildRequestForCurrentAndUnsavedBuffers_test( @YouCompleteMeInstance() def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test( ycm ): - current_buffer_file = os.path.realpath( 'current_buffer' ) + current_buffer_file = os.path.realpath( 'current_βuffer' ) current_buffer = VimBuffer( name = current_buffer_file, number = 1, contents = [ 'current_buffer_contents' ], filetype = 'some_filetype', modified = True ) - deleted_buffer_file = os.path.realpath( 'deleted_buffer' ) + deleted_buffer_file = os.path.realpath( 'deleted_βuffer' ) deleted_buffer = VimBuffer( name = deleted_buffer_file, number = 2, contents = [ 'deleted_buffer_contents' ], @@ -464,7 +465,7 @@ def EventNotification_BufferUnload_BuildRequestForDeletedAndUnsavedBuffers_test( with patch( 'ycm.client.event_notification.EventNotification.' 'PostDataToHandlerAsync' ) as post_data_to_handler_async: with MockVimBuffers( [ current_buffer, deleted_buffer ], current_buffer ): - ycm.OnBufferUnload( deleted_buffer_file ) + ycm.OnBufferUnload( ToBytesOnPY2( deleted_buffer_file ) ) assert_that( # Positional arguments passed to PostDataToHandlerAsync. From 1e935db4b7c62e4f857c9f067bc797d6ea264901 Mon Sep 17 00:00:00 2001 From: micbou Date: Wed, 5 Jul 2017 01:00:33 +0200 Subject: [PATCH 2/2] Fix unicode warning when unloading buffer on Python 2 --- python/ycm/youcompleteme.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/ycm/youcompleteme.py b/python/ycm/youcompleteme.py index f2087d81..cb7dcc5e 100644 --- a/python/ycm/youcompleteme.py +++ b/python/ycm/youcompleteme.py @@ -374,7 +374,9 @@ class YouCompleteMe( object ): def OnBufferUnload( self, deleted_buffer_file ): - SendEventNotificationAsync( 'BufferUnload', filepath = deleted_buffer_file ) + SendEventNotificationAsync( + 'BufferUnload', + filepath = utils.ToUnicode( deleted_buffer_file ) ) def OnBufferVisit( self ):