Skip to content

Commit

Permalink
fix: avoid triggering global logging config
Browse files Browse the repository at this point in the history
Closes #332
  • Loading branch information
tseaver committed Dec 1, 2020
1 parent 63ff233 commit 786cb97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion google/cloud/storage/blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions tests/unit/test_blob.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
)
Expand Down

0 comments on commit 786cb97

Please sign in to comment.