Fix CheckFilename test on Windows and Py2
On Windows and Python 2, the full exception message from IOError in CheckFilename will contain the filepath formatted as a unicode string. Since the filepath is already added in the RuntimeError message, use the strerror attribute to only display the error.
This commit is contained in:
parent
1b0a8ea6e8
commit
f981370965
@ -1153,7 +1153,7 @@ def CheckFilename_test():
|
|||||||
calling( vimsupport.CheckFilename ).with_args( 'nonexistent_file' ),
|
calling( vimsupport.CheckFilename ).with_args( 'nonexistent_file' ),
|
||||||
raises( RuntimeError,
|
raises( RuntimeError,
|
||||||
"filename 'nonexistent_file' cannot be opened. "
|
"filename 'nonexistent_file' cannot be opened. "
|
||||||
"\[Errno 2\] No such file or directory: 'nonexistent_file'" )
|
"No such file or directory." )
|
||||||
)
|
)
|
||||||
|
|
||||||
assert_that( vimsupport.CheckFilename( __file__ ), none() )
|
assert_that( vimsupport.CheckFilename( __file__ ), none() )
|
||||||
|
@ -849,7 +849,8 @@ def CheckFilename( filename ):
|
|||||||
raise RuntimeError( "'{0}' is not a valid filename".format( filename ) )
|
raise RuntimeError( "'{0}' is not a valid filename".format( filename ) )
|
||||||
except IOError as error:
|
except IOError as error:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
"filename '{0}' cannot be opened. {1}".format( filename, error ) )
|
"filename '{0}' cannot be opened. {1}.".format( filename,
|
||||||
|
error.strerror ) )
|
||||||
|
|
||||||
|
|
||||||
def BufferIsVisibleForFilename( filename ):
|
def BufferIsVisibleForFilename( filename ):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user