diff --git a/google/cloud/storage/_media/requests/download.py b/google/cloud/storage/_media/requests/download.py index 6222148b3..67535f923 100644 --- a/google/cloud/storage/_media/requests/download.py +++ b/google/cloud/storage/_media/requests/download.py @@ -387,7 +387,6 @@ def _write_to_stream(self, response): msg += content_length_msg raise DataCorruption(response, msg) - def consume( self, transport, diff --git a/google/cloud/storage/fileio.py b/google/cloud/storage/fileio.py index 2b4754648..289a09cee 100644 --- a/google/cloud/storage/fileio.py +++ b/google/cloud/storage/fileio.py @@ -477,7 +477,7 @@ def write(self, b): self._buffer.seek(0, io.SEEK_END) pos = self._buffer.write(b) self._buffer.seek(bookmark) - return self._cursor + pos + return pos def read(self, size=-1): """Read and move the cursor.""" diff --git a/tests/unit/test_fileio.py b/tests/unit/test_fileio.py index 8da25d9e3..920a3c4c2 100644 --- a/tests/unit/test_fileio.py +++ b/tests/unit/test_fileio.py @@ -367,12 +367,14 @@ def test_write(self, mock_warn): # Write under chunk_size. This should be buffered and the upload not # initiated. - writer.write(TEST_BINARY_DATA[0:4]) + w1 = writer.write(TEST_BINARY_DATA[0:4]) + self.assertEqual(w1, 4) blob._initiate_resumable_upload.assert_not_called() # Write over chunk_size. This should result in upload initialization # and multiple chunks uploaded. - writer.write(TEST_BINARY_DATA[4:32]) + w2 = writer.write(TEST_BINARY_DATA[4:32]) + self.assertEqual(w2, 28) blob._initiate_resumable_upload.assert_called_once_with( blob.bucket.client, writer._buffer,