diff --git a/python/ycm/tests/syntax_parse_test.py b/python/ycm/tests/syntax_parse_test.py index dc2e61ae..8fe5c79c 100644 --- a/python/ycm/tests/syntax_parse_test.py +++ b/python/ycm/tests/syntax_parse_test.py @@ -30,12 +30,13 @@ import os from nose.tools import eq_ from hamcrest import assert_that, has_items from ycm import syntax_parse +from ycmd.utils import ReadFile def ContentsOfTestFile( test_file ): dir_of_script = os.path.dirname( os.path.abspath( __file__ ) ) full_path_to_test_file = os.path.join( dir_of_script, 'testdata', test_file ) - return open( full_path_to_test_file ).read() + return ReadFile( full_path_to_test_file ) diff --git a/python/ycm/vimsupport.py b/python/ycm/vimsupport.py index b44ca109..963d6746 100644 --- a/python/ycm/vimsupport.py +++ b/python/ycm/vimsupport.py @@ -837,7 +837,9 @@ def WriteToPreviewWindow( message ): def CheckFilename( filename ): """Check if filename is openable.""" try: - open( filename ).close() + # We don't want to check for encoding issues when trying to open the file + # so we open it in binary mode. + open( filename, mode = 'rb' ).close() except TypeError: raise RuntimeError( "'{0}' is not a valid filename".format( filename ) ) except IOError as error: