Skip to content

[3.10] bpo-44048: Fix two hashlib test cases under FIPS mode (GH-26470) #26531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Lib/test/test_hashlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down