Skip to content

Commit 955a91b

Browse files
authored
fix(storage): test_transfer_manager counts unwanted deprecated warnings (#16744)
test_transfer_manager::test_download_many_to_path_raises_invalid_path_error catches all types of warnings (including FutureWarnings and DeprecationWarnings) whereas it is only required to check invalid path warnings. Fixed the test to only include invalid_path_warnings
1 parent b8b457a commit 955a91b

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

packages/google-cloud-storage/tests/unit/test_fileio.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,8 +922,8 @@ def test_write(self, mock_warn):
922922

923923
# The transmit_next_chunk method must actually consume bytes from the
924924
# sliding buffer for the flush() feature to work properly.
925-
upload.transmit_next_chunk.side_effect = (
926-
lambda _: unwrapped_writer._buffer.read(chunk_size)
925+
upload.transmit_next_chunk.side_effect = lambda _: (
926+
unwrapped_writer._buffer.read(chunk_size)
927927
)
928928

929929
# Write under chunk_size. This should be buffered and the upload not

packages/google-cloud-storage/tests/unit/test_transfer_manager.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,17 @@ def test_download_many_to_path_raises_invalid_path_error():
556556
skip_if_exists=True,
557557
)
558558

559-
assert len(w) == 1
560-
assert "will **NOT** be downloaded" in str(w[0].message)
559+
invalid_path_warnings = [
560+
warning
561+
for warning in w
562+
if str(warning.message).startswith("The blob ")
563+
and "will **NOT** be downloaded" in str(warning.message)
564+
]
565+
566+
assert len(invalid_path_warnings) == 1, (
567+
f"Expected 1 invalid path warning, found {len(invalid_path_warnings)}. All warnings: {[str(warning.message) for warning in w]}"
568+
)
569+
561570
assert len(results) == 1
562571
assert isinstance(results[0], UserWarning)
563572

0 commit comments

Comments
 (0)