Skip to content

Commit 7fee3dd

Browse files
authored
fix: flaky system tests for resumable_media (#1592)
* fix: flaky system tests for resumable_media * resolving comments
1 parent 961536c commit 7fee3dd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/resumable_media/system/requests/test_download.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import http.client
1919
import io
2020
import os
21+
import sys
2122

2223
import google.auth # type: ignore
2324
import google.auth.transport.requests as tr_requests # type: ignore
@@ -63,7 +64,11 @@ class CorruptingAuthorizedSession(tr_requests.AuthorizedSession):
6364
constructor.
6465
"""
6566

66-
EMPTY_MD5 = base64.b64encode(hashlib.md5(b"").digest()).decode("utf-8")
67+
EMPTY_MD5 = base64.b64encode(
68+
hashlib.md5(
69+
b"", **({"usedforsecurity": False} if sys.version_info >= (3, 9) else {})
70+
).digest()
71+
).decode("utf-8")
6772
crc32c = google_crc32c.Checksum()
6873
crc32c.update(b"")
6974
EMPTY_CRC32C = base64.b64encode(crc32c.digest()).decode("utf-8")

tests/resumable_media/system/requests/test_upload.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import io
1919
import os
2020
import urllib.parse
21+
import sys
2122

2223
import pytest # type: ignore
2324
from unittest import mock
@@ -73,7 +74,9 @@ def img_stream():
7374

7475

7576
def get_md5(data):
76-
hash_obj = hashlib.md5(data)
77+
hash_obj = hashlib.md5(
78+
data, **({"usedforsecurity": False} if sys.version_info >= (3, 9) else {})
79+
)
7780
return base64.b64encode(hash_obj.digest())
7881

7982

0 commit comments

Comments
 (0)