summaryrefslogtreecommitdiff
path: root/Lib/test/test_hashlib.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-06-04 11:38:02 -0700
committerGitHub <noreply@github.com>2021-06-04 19:38:02 +0100
commit3f4d801bf907a5fcab50f3b64475d1410b90a80f (patch)
tree55797c66ab8198d257426503d59ccde82b610b1a /Lib/test/test_hashlib.py
parente53f72a1b42e17a331ed14bec674b1ee01d0720c (diff)
downloadcpython-git-3f4d801bf907a5fcab50f3b64475d1410b90a80f.tar.gz
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@redhat.com> Co-authored-by: stratakis <cstratak@redhat.com>
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r--Lib/test/test_hashlib.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py
index ad2ed69e24..76754b6b8e 100644
--- a/Lib/test/test_hashlib.py
+++ b/Lib/test/test_hashlib.py
@@ -909,7 +909,11 @@ class HashLibTestCase(unittest.TestCase):
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 @@ class HashLibTestCase(unittest.TestCase):
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