File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1313- Added FTP over TLS (FTPS) support to FTPFS.
1414 Closes [ #437 ] ( https://github.com/PyFilesystem/pyfilesystem2/issues/437 ) ,
1515 [ #449 ] ( https://github.com/PyFilesystem/pyfilesystem2/pull/449 ) .
16+ - ` PathError ` now supports wrapping an exception using the ` exc ` argument.
17+ Closes [ #453 ] ( https://github.com/PyFilesystem/pyfilesystem2/issues/453 ) .
1618
1719### Changed
1820
Original file line number Diff line number Diff line change 33import errno
44import unittest
55
6+ import fs .errors
67from fs .error_tools import convert_os_errors
7- from fs import errors as fserrors
88
99
1010class TestErrorTools (unittest .TestCase ):
11- def assert_convert_os_errors (self ):
11+ def test_convert_enoent (self ):
12+ exception = OSError (errno .ENOENT , "resource not found" )
13+ with self .assertRaises (fs .errors .ResourceNotFound ) as ctx :
14+ with convert_os_errors ("stat" , "/tmp/test" ):
15+ raise exception
16+ self .assertEqual (ctx .exception .exc , exception )
17+ self .assertEqual (ctx .exception .path , "/tmp/test" )
1218
13- with self .assertRaises (fserrors .ResourceNotFound ):
14- with convert_os_errors ("foo" , "test" ):
15- raise OSError (errno .ENOENT )
19+ def test_convert_enametoolong (self ):
20+ exception = OSError (errno .ENAMETOOLONG , "File name too long: test" )
21+ with self .assertRaises (fs .errors .PathError ) as ctx :
22+ with convert_os_errors ("stat" , "/tmp/test" ):
23+ raise exception
24+ self .assertEqual (ctx .exception .exc , exception )
25+ self .assertEqual (ctx .exception .path , "/tmp/test" )
You can’t perform that action at this time.
0 commit comments