aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/test/test_hashlib.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@python.org>2019-09-13 15:31:19 +0200
committerGregory P. Smith <greg@krypto.org>2019-09-13 14:31:19 +0100
commit995b5d38e7cc24cac3de8dfd516115f86b0bcf80 (patch)
tree24e2115e689a8f777294b0b18c0bd7da851a5a23 /Lib/test/test_hashlib.py
parent375a3e2bdbeb4dce69aba4b5bc90f55fe27e81b4 (diff)
downloadcpython-995b5d38e7cc24cac3de8dfd516115f86b0bcf80.tar.gz
cpython-995b5d38e7cc24cac3de8dfd516115f86b0bcf80.zip
bpo-38153: Normalize hashlib algorithm names (GH-16083)
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r--Lib/test/test_hashlib.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index 46088e52dc5..9204b44bf4f 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -27,6 +27,11 @@ c_hashlib = import_fresh_module('hashlib', fresh=['_hashlib'])
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 @@ class HashLibTestCase(unittest.TestCase):
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 @@ class KDFTests(unittest.TestCase):
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()