summaryrefslogtreecommitdiff
path: root/Lib/test/test_hmac.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_hmac.py')
-rw-r--r--Lib/test/test_hmac.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_hmac.py b/Lib/test/test_hmac.py
index 7cf99735ca..a39a2c45eb 100644
--- a/Lib/test/test_hmac.py
+++ b/Lib/test/test_hmac.py
@@ -373,6 +373,16 @@ class TestVectorsTestCase(unittest.TestCase):
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):