python: Report detailed error message when opening fsread1 channel fails
Teach check_open() about validating the `message` part of `close`, when given.
This commit is contained in:
parent
60291fd727
commit
3151a8c9bf
|
@ -109,8 +109,8 @@ class FsReadChannel(GeneratorChannel):
|
|||
return {'tag': '-'}
|
||||
except PermissionError:
|
||||
raise ChannelError('access-denied')
|
||||
except OSError:
|
||||
raise ChannelError('internal-error')
|
||||
except OSError as error:
|
||||
raise ChannelError('internal-error', message=str(error)) from error
|
||||
|
||||
|
||||
class FsReplaceChannel(Channel):
|
||||
|
|
|
@ -510,3 +510,9 @@ class TestBridge(unittest.IsolatedAsyncioTestCase):
|
|||
assert not all(d for d in data[0][0])
|
||||
# memory.used should be an integer
|
||||
assert isinstance(data[0][1], int)
|
||||
|
||||
async def test_fsread1_errors(self):
|
||||
await self.start()
|
||||
await self.transport.check_open('fsread1', path='/etc/shadow', problem='access-denied')
|
||||
await self.transport.check_open('fsread1', path='/', problem='internal-error',
|
||||
reply_keys={'message': "[Errno 21] Is a directory: '/'"})
|
||||
|
|
Loading…
Reference in New Issue