@@ -264,7 +264,10 @@ def test_clinic_signature(self):
264264 hashlib .new (digest_name , b'' )
265265 hashlib .new (digest_name , data = b'' )
266266 hashlib .new (digest_name , string = b'' )
267- if self ._hashlib :
267+ # Make sure that _hashlib contains the constructor
268+ # to test when using a combination of libcrypto and
269+ # interned hash implementations.
270+ if self ._hashlib and digest_name in self ._hashlib ._constructors :
268271 self ._hashlib .new (digest_name , b'' )
269272 self ._hashlib .new (digest_name , data = b'' )
270273 self ._hashlib .new (digest_name , string = b'' )
@@ -316,7 +319,8 @@ def test_clinic_signature_errors(self):
316319 with self .subTest (digest_name , args = args , kwds = kwds ):
317320 with self .assertRaisesRegex (TypeError , errmsg ):
318321 hashlib .new (digest_name , * args , ** kwds )
319- if self ._hashlib :
322+ if (self ._hashlib and
323+ digest_name in self ._hashlib ._constructors ):
320324 with self .assertRaisesRegex (TypeError , errmsg ):
321325 self ._hashlib .new (digest_name , * args , ** kwds )
322326
0 commit comments