Skip to content

Commit a269861

Browse files
committed
test: adjusts assert to account for potential race condition
1 parent 5aa2cfe commit a269861

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/google-cloud-storage/tests/system/test_zonal.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,15 @@ async def _run():
722722

723723
for i in range(num_chunks):
724724
if i % 2 == 0:
725-
assert isinstance(results[i], asyncio.CancelledError)
725+
# In fast environments, the task might complete before cancellation takes effect.
726+
# We accept either Cancellation or successful completion to avoid flakiness.
727+
if isinstance(results[i], asyncio.CancelledError):
728+
pass
729+
else:
730+
assert results[i] is None
731+
start = i * chunk_size
732+
expected_data = object_data[start : start + chunk_size]
733+
assert buffers[i].getvalue() == expected_data
726734
else:
727735
start = i * chunk_size
728736
expected_data = object_data[start : start + chunk_size]

0 commit comments

Comments
 (0)