Content-Length: 320700 | pFad | https://github.com/python/cpython/commit/f93e1ba3e0e3dac93e2dcb0ccbc8587ddebea1af

3E Update test_hmac.py · python/cpython@f93e1ba · GitHub
Skip to content

Commit f93e1ba

Browse files
authored
Update test_hmac.py
1 parent d0079c6 commit f93e1ba

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Lib/test/test_hmac.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,14 +1505,12 @@ def test_with_fallback(self):
15051505
cache.pop('foo')
15061506

15071507
@hashlib_helper.requires_builtin_hashdigest("_md5", "md5")
1508-
@bigmemtest(size=_4G, memuse=2, dry_run=False)
1508+
@bigmemtest(size=_4G , memuse=2, dry_run=False)
15091509
def test_hmac_digest_overflow_error_no_openssl(self, size):
15101510
hmac = import_fresh_module("hmac", blocked=["_hashlib"])
15111511

1512-
UINT32_MAX = (1 << 32) - 1
1513-
self.assertEqual(UINT32_MAX, size - 1)
1514-
bigkey = b'K' * UINT32_MAX
1515-
bigmsg = b'M' * UINT32_MAX
1512+
bigkey = b'K' * size
1513+
bigmsg = b'M' * size
15161514

15171515
with unittest.mock.patch.object(hmac, "_compute_digest_fallback") as f:
15181516
self.assertRaises(OverflowError, hmac.digest, bigkey, b'm', "md5")
@@ -1525,18 +1523,17 @@ def test_hmac_digest_overflow_error_no_builtin(self, size):
15251523
capi = import_helper.import_module("_testcapi")
15261524
hmac = import_fresh_module("hmac", blocked=["_hmac"])
15271525

1528-
INT_MAX = capi.INT_MAX
1529-
self.assertLessEqual(INT_MAX, size)
1530-
bigkey = b'K' * INT_MAX
1531-
bigmsg = b'M' * INT_MAX
1526+
self.assertLess(capi.INT_MAX, size)
1527+
bigkey = b'K' * size
1528+
bigmsg = b'M' * size
15321529

15331530
with unittest.mock.patch.object(hmac, "_compute_digest_fallback") as f:
15341531
self.assertRaises(OverflowError, hmac.digest, bigkey, b'm', "md5")
15351532
self.assertRaises(OverflowError, hmac.digest, b'k', bigmsg, "md5")
15361533
f.assert_not_called()
15371534

15381535
@hashlib_helper.requires_hashdigest("md5", openssl=True)
1539-
@bigmemtest(size=_4G + 1, memuse=2, dry_run=False)
1536+
@bigmemtest(size=_4G, memuse=2, dry_run=False)
15401537
def test_hmac_digest_no_overflow_error_in_fallback(self, size):
15411538
hmac = import_fresh_module("hmac", blocked=["_hashlib", "_hmac"])
15421539

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/python/cpython/commit/f93e1ba3e0e3dac93e2dcb0ccbc8587ddebea1af

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy