[Python-checkins] bpo-44048: Fix two hashlib test cases under FIPS mode (GH-26470) (GH-26531)
pablogsal
webhook-mailer at python.org
Fri Jun 4 14:38:10 EDT 2021
https://github.com/python/cpython/commit/3f4d801bf907a5fcab50f3b64475d1410b90a80f
commit: 3f4d801bf907a5fcab50f3b64475d1410b90a80f
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-06-04T19:38:02+01:00
summary:
bpo-44048: Fix two hashlib test cases under FIPS mode (GH-26470) (GH-26531)
test_disallow_instantiation and test_readonly_types try to test all the available
digests, however under FIPS mode, while the algorithms are available, trying to use
them will fail with a ValueError.
(cherry picked from commit a46c220edc5cf716d0b71eb80ac29ecdb4ebb430)
Co-authored-by: stratakis <cstratak at redhat.com>
Co-authored-by: stratakis <cstratak at redhat.com>
files:
M Lib/test/test_hashlib.py
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index ad2ed69e24b2c4..76754b6b8e13da 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -909,7 +909,11 @@ def test_disallow_instantiation(self):
continue
# all other types have DISALLOW_INSTANTIATION
for constructor in constructors:
- h = constructor()
+ # In FIPS mode some algorithms are not available raising ValueError
+ try:
+ h = constructor()
+ except ValueError:
+ continue
with self.subTest(constructor=constructor):
hash_type = type(h)
self.assertRaises(TypeError, hash_type)
@@ -930,7 +934,11 @@ def test_readonly_types(self):
for algorithm, constructors in self.constructors_to_test.items():
# all other types have DISALLOW_INSTANTIATION
for constructor in constructors:
- hash_type = type(constructor())
+ # In FIPS mode some algorithms are not available raising ValueError
+ try:
+ hash_type = type(constructor())
+ except ValueError:
+ continue
with self.subTest(hash_type=hash_type):
with self.assertRaisesRegex(TypeError, "immutable type"):
hash_type.value = False
More information about the Python-checkins
mailing list