Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Write file once
  • Loading branch information
tiran committed Mar 21, 2022
commit 884310285022e37199d7e89eab52b37d510ff8f8
12 changes: 7 additions & 5 deletions Lib/test/test_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,24 @@ def check_file_digest(self, name, data, hexdigest):
digests = [name]
digests.extend(self.constructors_to_test[name])

for digest in digests:
with self.subTest(digest=digest):
with open(os_helper.TESTFN, "wb") as f:
f.write(data)

try:
for digest in digests:
buf = io.BytesIO(data)
buf.seek(0)
self.assertEqual(
hashlib.file_digest(buf, digest).hexdigest(), hexdigest
Comment thread
gpshead marked this conversation as resolved.
)
with open(os_helper.TESTFN, "wb") as f:
f.write(data)
try:
with open(os_helper.TESTFN, "rb") as f:
digestobj = hashlib.file_digest(f, digest)
finally:
os.unlink(os_helper.TESTFN)
Comment thread
tiran marked this conversation as resolved.
Outdated
self.assertEqual(digestobj.hexdigest(), hexdigest)

finally:
os.unlink(os_helper.TESTFN)

def check_no_unicode(self, algorithm_name):
# Unicode objects are not allowed as input.
Expand Down