def test_unicode_read(self): path = self.get_test_path('test_unicode_read.txt') key = self.get_key(path) with self.cleaning(path): key.set_contents_from_string(QUOTE_CH) eq_(QUOTE_CH.encode('utf-8'), s3file.open(key, 'r').read()) eq_(QUOTE_CH.encode('utf-8')[:4], s3file.open(key, 'r').read(length=4))
def test_basic_read(self): path = self.get_test_path('test_basic_read.txt') key = self.get_key(path) with self.cleaning(path): key.set_contents_from_string(QUOTE_EN) eq_(QUOTE_EN, s3file.open(key, 'r').read()) eq_(QUOTE_EN[:4], s3file.open(key, 'r').read(length=4))
def test_seek(self): path = self.get_test_path('test_seek.txt') key = self.get_key(path) with self.cleaning(path): key.set_contents_from_string(QUOTE_EN) f = s3file.open(key, 'r') f.seek(0, os.SEEK_SET) eq_(QUOTE_EN[:2], f.read(2)) f.seek(1, os.SEEK_SET) eq_(QUOTE_EN[1:][:2], f.read(2)) f.seek(-1, os.SEEK_END) eq_(QUOTE_EN[-1:], f.read()) f.seek(0, os.SEEK_SET) f.seek(2, os.SEEK_CUR) eq_(QUOTE_EN[2:][:2], f.read(2))
def open(self, path, mode='r'): key = self._get_key(path, validate=True) if key is None: raise S3FileSystemException("No such file or directory: '%s'" % path) return s3file.open(key, mode=mode)
def open(self, path, mode='r'): key = self._get_key(path, validate=True) if key is None: raise IOError(errno.ENOENT, "No such file or directory: '%s'" % path) return s3file.open(key, mode=mode)