def test_getbytes(self):
# Test getbytes method.
all_bytes = b''.join(six.int2byte(n) for n in range(256))
with self.fs.open('foo', 'wb') as f:
f.write(all_bytes)
self.assertEqual(self.fs.getbytes('foo'), all_bytes)
_all_bytes = self.fs.getbytes('foo')
self.assertIsInstance(_all_bytes, bytes)
self.assertEqual(_all_bytes, all_bytes)
with self.assertRaises(errors.ResourceNotFound):
self.fs.getbytes('foo/bar')
self.fs.makedir('baz')
with self.assertRaises(errors.FileExpected):
self.fs.getbytes('baz')
评论列表
文章目录