mirror of
https://github.com/python/cpython.git
synced 2025-10-12 01:43:12 +00:00
bpo-44048: Fix two hashlib test cases under FIPS mode (GH-26470)
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.
This commit is contained in:
parent
6ab65c670d
commit
a46c220edc
1 changed files with 10 additions and 2 deletions
|
@ -909,7 +909,11 @@ class HashLibTestCase(unittest.TestCase):
|
||||||
continue
|
continue
|
||||||
# all other types have DISALLOW_INSTANTIATION
|
# all other types have DISALLOW_INSTANTIATION
|
||||||
for constructor in constructors:
|
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):
|
with self.subTest(constructor=constructor):
|
||||||
support.check_disallow_instantiation(self, type(h))
|
support.check_disallow_instantiation(self, type(h))
|
||||||
|
|
||||||
|
@ -923,7 +927,11 @@ class HashLibTestCase(unittest.TestCase):
|
||||||
for algorithm, constructors in self.constructors_to_test.items():
|
for algorithm, constructors in self.constructors_to_test.items():
|
||||||
# all other types have DISALLOW_INSTANTIATION
|
# all other types have DISALLOW_INSTANTIATION
|
||||||
for constructor in constructors:
|
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.subTest(hash_type=hash_type):
|
||||||
with self.assertRaisesRegex(TypeError, "immutable type"):
|
with self.assertRaisesRegex(TypeError, "immutable type"):
|
||||||
hash_type.value = False
|
hash_type.value = False
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue