◐ Shell
clean mode source ↗

[3.11] gh-103256: Fix hmac algorithm to support fallback implementation (gh-103286) by miss-islington · Pull Request #103328 · python/cpython

Expand Up @@ -373,6 +373,16 @@ def test_with_digestmod_no_default(self): with self.assertRaisesRegex(TypeError, r'required.*digestmod'): hmac.HMAC(key, msg=data, digestmod='')
def test_with_fallback(self): cache = getattr(hashlib, '__builtin_constructor_cache') try: cache['foo'] = hashlib.sha256 hexdigest = hmac.digest(b'key', b'message', 'foo').hex() expected = '6e9ef29b75fffc5b7abae527d58fdadb2fe42e7219011976917343065f58ed4a' self.assertEqual(hexdigest, expected) finally: cache.pop('foo')

class ConstructorTestCase(unittest.TestCase):
Expand Down