Skip to content
Permalink
Browse files
fix: avoid triggering global logging config (#333)
Closes #332
  • Loading branch information
tseaver committed Dec 1, 2020
1 parent 6ef1de2 commit 602108a976503271fe0d85c8d7891ce8083aca89
Showing with 7 additions and 3 deletions.
  1. +3 −1 google/cloud/storage/blob.py
  2. +4 −2 tests/unit/test_blob.py
@@ -122,6 +122,8 @@
_DEFAULT_CHUNKSIZE = 104857600 # 1024 * 1024 B * 100 = 100 MB
_MAX_MULTIPART_SIZE = 8388608 # 8 MB

_logger = logging.getLogger(__name__)


class Blob(_PropertyMixin):
"""A wrapper around Cloud Storage's concept of an ``Object``.
@@ -923,7 +925,7 @@ def _do_download(

if checksum:
msg = _CHUNKED_DOWNLOAD_CHECKSUM_MESSAGE.format(checksum)
logging.info(msg)
_logger.info(msg)

if raw_download:
klass = RawChunkedDownload
@@ -1115,7 +1115,7 @@ def test__do_download_w_chunks_w_custom_timeout(self):
def test__do_download_w_chunks_w_checksum(self):
from google.cloud.storage import blob as blob_module

with mock.patch("logging.info") as patch:
with mock.patch.object(blob_module._logger, "info") as patch:
self._do_download_helper_w_chunks(
w_range=False, raw_download=False, checksum="md5"
)
@@ -1124,7 +1124,9 @@ def test__do_download_w_chunks_w_checksum(self):
)

def test__do_download_w_chunks_wo_checksum(self):
with mock.patch("logging.info") as patch:
from google.cloud.storage import blob as blob_module

with mock.patch.object(blob_module._logger, "info") as patch:
self._do_download_helper_w_chunks(
w_range=False, raw_download=False, checksum=None
)

0 comments on commit 602108a

Please sign in to comment.