Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid triggering global logging config #333

Merged
merged 2 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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