Skip to content

Commit eebb4a2

Browse files
committed
Add regression test for #453 and update CHANGELOG.md
1 parent f412cb4 commit eebb4a2

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

tests/test_error_tools.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,23 @@
33
import errno
44
import unittest
55

6+
import fs.errors
67
from fs.error_tools import convert_os_errors
7-
from fs import errors as fserrors
88

99

1010
class 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")

0 commit comments

Comments
 (0)