Fix LookupError exception when opening a file
Open the file in binary mode in CheckFilename function. Use ReadFile helper in syntax_parse tests.
This commit is contained in:
parent
87f0f7e16d
commit
b0786d5c4f
@ -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 )
|
||||
|
||||
|
||||
|
||||
|
@ -851,7 +851,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:
|
||||
|
Loading…
Reference in New Issue
Block a user