bpo-38153: Normalize hashlib algorithm names (GH-16083)
Signed-off-by: Christian Heimes <christian@python.org>
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 46088e5..9204b44 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -27,6 +27,11 @@
py_hashlib = import_fresh_module('hashlib', blocked=['_hashlib'])
try:
+ from _hashlib import HASH
+except ImportError:
+ HASH = None
+
+try:
import _blake2
except ImportError:
_blake2 = None
@@ -386,6 +391,9 @@
constructors = self.constructors_to_test[name]
for hash_object_constructor in constructors:
m = hash_object_constructor()
+ if HASH is not None and isinstance(m, HASH):
+ # _hashopenssl's variant does not have extra SHA3 attributes
+ continue
self.assertEqual(capacity + rate, 1600)
self.assertEqual(m._capacity_bits, capacity)
self.assertEqual(m._rate_bits, rate)
@@ -985,6 +993,10 @@
hashlib.scrypt(b'password', salt=b'salt', n=2, r=8, p=1,
dklen=dklen)
+ def test_normalized_name(self):
+ self.assertNotIn("blake2b512", hashlib.algorithms_available)
+ self.assertNotIn("sha3-512", hashlib.algorithms_available)
+
if __name__ == "__main__":
unittest.main()