@@ -263,7 +263,10 @@ def test_clinic_signature(self):
263263 hashlib .new (digest_name , b'' )
264264 hashlib .new (digest_name , data = b'' )
265265 hashlib .new (digest_name , string = b'' )
266- if self ._hashlib :
266+ # Make sure that _hashlib contains the constructor
267+ # to test when using a combination of libcrypto and
268+ # interned hash implementations.
269+ if self ._hashlib and digest_name in self ._hashlib ._constructors :
267270 self ._hashlib .new (digest_name , b'' )
268271 self ._hashlib .new (digest_name , data = b'' )
269272 self ._hashlib .new (digest_name , string = b'' )
@@ -315,7 +318,8 @@ def test_clinic_signature_errors(self):
315318 with self .subTest (digest_name , args = args , kwds = kwds ):
316319 with self .assertRaisesRegex (TypeError , errmsg ):
317320 hashlib .new (digest_name , * args , ** kwds )
318- if self ._hashlib :
321+ if (self ._hashlib and
322+ digest_name in self ._hashlib ._constructors ):
319323 with self .assertRaisesRegex (TypeError , errmsg ):
320324 self ._hashlib .new (digest_name , * args , ** kwds )
321325
0 commit comments