예제 #1
0
 def test_read_chunks(self):
     with XZ.open('../data/blob.more.xz') as xz:
         chunk = xz.read(8)
         assert chunk == 'Some dat'
         chunk = xz.read(8)
         assert chunk == 'a so tha'
         chunk = xz.read(8)
         assert chunk == 't we can'
         chunk = xz.read(8)
         assert chunk == ' read it'
         chunk = xz.read(8)
         assert chunk == ' as mult'
         chunk = xz.read(8)
         assert chunk == 'iple chu'
         chunk = xz.read(8)
         assert chunk == 'nks'
예제 #2
0
 def setup(self):
     self.xz = XZ.open('../data/blob.xz')
예제 #3
0
 def test_uncompressed_size(self):
     assert XZ.uncompressed_size('../data/blob.xz') == 4
예제 #4
0
 def test_read_raise(self, mock_xz):
     mock_xz.flush = 'data-which-should-never-be-there'
     with XZ.open('../data/blob.more.xz') as xz:
         chunk = xz.read(8)
예제 #5
0
 def test_uncompressed_size_raise(self, mock_popen):
     mock_xz = mock.Mock()
     mock_xz.communicate = mock.Mock(return_value=['data', 'error'])
     mock_popen.returncode = 1
     mock_popen.return_value = mock_xz
     XZ.uncompressed_size('../data/blob.xz')
예제 #6
0
파일: storage.py 프로젝트: jesusbv/azurectl
 def __upload_byte_size(self, image, image_type):
     if image_type.is_xz():
         return XZ.uncompressed_size(image)
     return os.path.getsize(image)
예제 #7
0
파일: storage.py 프로젝트: jesusbv/azurectl
 def __open_upload_stream(self, image, image_type):
     if image_type.is_xz():
         return XZ.open(image)
     return open(image)