diff options
author | stratakis <cstratak@redhat.com> | 2021-06-04 16:47:59 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-04 16:47:59 (GMT) |
commit | a46c220edc5cf716d0b71eb80ac29ecdb4ebb430 (patch) | |
tree | 37cd2726cd17e5a7be0a40719c043f6a720f9b8c /Lib/test/test_hashlib.py | |
parent | 6ab65c670dd9e9b95f363e25e308d6fc2f4fe92a (diff) | |
download | cpython-a46c220edc5cf716d0b71eb80ac29ecdb4ebb430.zip cpython-a46c220edc5cf716d0b71eb80ac29ecdb4ebb430.tar.gz cpython-a46c220edc5cf716d0b71eb80ac29ecdb4ebb430.tar.bz2 |
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.
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r-- | Lib/test/test_hashlib.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index e419b38..1623bf3 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): support.check_disallow_instantiation(self, type(h)) @@ -923,7 +927,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 |